]> git.parisson.com Git - teleforma.git/commitdiff
detect iOS for download / streaming
authorGuillaume Pellerin <yomguy@parisson.com>
Fri, 17 Jul 2015 17:01:23 +0000 (19:01 +0200)
committerGuillaume Pellerin <yomguy@parisson.com>
Fri, 17 Jul 2015 17:01:23 +0000 (19:01 +0200)
example/settings.py
setup.py
teleforma/exam/views.py
teleforma/templates/teleforma/course_media.html

index 534a6796447bde0af761ec5f3675dc37b2560404..b840468a1111803005f0e6d179b31a518caa115b 100644 (file)
@@ -111,6 +111,7 @@ MIDDLEWARE_CLASSES = (
     'django.contrib.messages.middleware.MessageMiddleware',
     'django.middleware.locale.LocaleMiddleware',
     'pagination.middleware.PaginationMiddleware',
+    'django_user_agents.middleware.UserAgentMiddleware',
 )
 
 ROOT_URLCONF = 'urls'
@@ -151,6 +152,7 @@ INSTALLED_APPS = (
      # 'telecaster',
      'extra_views',
      'captcha',
+     'django_user_agents',
 )
 
 TEMPLATE_CONTEXT_PROCESSORS = (
@@ -217,3 +219,15 @@ SOUTH_MIGRATION_MODULES = {
 SUIT_CONFIG = {
     'ADMIN_NAME': 'TeleForma Admin',
 }
+
+# Cache backend is optional, but recommended to speed up user agent parsing
+CACHES = {
+    'default': {
+        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
+        'LOCATION': '127.0.0.1:11211',
+    }
+}
+
+# Name of cache backend to cache user agents. If it not specified default
+# cache alias will be used. Set to `None` to disable caching.
+USER_AGENTS_CACHE = 'default'
index 278c7e6c36801583b3c26e4a4dedff88d4177eef..b695542f73bd9e12a01fbc6a7d44ec7048eb0c98 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -29,6 +29,7 @@ setup(
         'django-simple-captcha',
         'django-suit',
         'django-nvd3',
+        'django-user-agents',
   ],
   platforms=['OS Independent'],
   license='CeCILL v2',
index 86a6f26145059e63704859505dc4074fffb9e668..836454773fa54dceb71761deb3c5ccdde93e3606 100644 (file)
@@ -66,7 +66,6 @@ class ScriptsView(ListView):
         context = super(ScriptsView, self).get_context_data(**kwargs)
         context['period'] = Period.objects.get(id=self.kwargs['period_id'])
         context['upload'] = getattr(settings, 'TELEFORMA_EXAM_SCRIPT_UPLOAD', True)
-        print self.request.user_agent.device
         return context
 
     @method_decorator(login_required)
index 076032c625c235c51718044d0af569f1893aa2d3..a0755ad7f8deee08cd3f4e146669d2ac55584d02 100644 (file)
@@ -59,7 +59,7 @@ $(document).ready(function(){
 
 {% block module-action %}
 {% if media.item.file and media.is_published or user.is_superuser or user.is_staff %}
- {% if not "video" in media.mime_type or perms.telemeta.can_play_all_items %}
+ {% if not "video" in media.mime_type or perms.telemeta.can_play_all_items or request.user_agent.os.family == 'iOS' %}
   <div class="module_action">
    <a href="{{ MEDIA_URL }}{{ media.item.file }}" class="component_icon button" id="action_red"><img src="{{STATIC_URL}}teleforma/images/download_media.png" alt="" style="vertical-align:middle" />&nbsp;{% trans "Download" %}</a>
   </div>