src/hdalab/views/pages.py
changeset 676 111906d4c8b0
parent 675 d68e7b3a2e4f
child 693 09e00f38d177
--- a/src/hdalab/views/pages.py	Thu Mar 31 14:13:00 2016 +0200
+++ b/src/hdalab/views/pages.py	Tue Apr 05 18:34:37 2016 +0200
@@ -15,13 +15,13 @@
 def datasheet(request, hda_id=None):
     MAX_TAG = 15
     MAX_RELATED = 50
-    
+
     datasheet = None
     try:
         datasheet = Datasheet.objects.select_related("organisation").get(hda_id=hda_id)
     except Datasheet.DoesNotExist:
         raise Http404("The datasheet %s is not found."%hda_id)
-    
+
     domain = re.findall(r"^https?://(www\.)?([^/]+)",datasheet.url)
     ordered_tags = TaggedSheet.objects.filter(datasheet=datasheet,order__lte=MAX_TAG).select_related("tag").order_by('order')
     tags = [t.tag.id for t in ordered_tags]
@@ -29,7 +29,7 @@
     tsqs = TaggedSheet.objects.exclude(datasheet=datasheet).filter(order__lte=MAX_TAG,tag_id__in=tags)
     dsscores = {}
     addtoscore = 2*MAX_TAG
-    
+
     for ts in tsqs:
         a_order = tagorders[ts.tag_id]
         b_order = ts.order
@@ -47,7 +47,7 @@
         'score': dsscores.get(ds.id,0),
     } for ds in relatedqs]
     relatedds = sorted(relatedds, key=lambda ds: -ds['score'])[:MAX_RELATED]
-    
+
     for ds in relatedds:
         otqs = TaggedSheet.objects.filter(datasheet_id=ds['id'],order__lte=MAX_TAG).select_related("tag").order_by('order')
         ds['ordered_tags'] = [{
@@ -56,7 +56,7 @@
             'order': t.order,
             'common' : (t.tag.id in tags)
         } for t in otqs]
-    
+
     return render_to_response(
         "notice.html",
         {
@@ -68,31 +68,16 @@
         context_instance=RequestContext(request)
     )
 
-OLDER_WINDOWS = [
-    u'Windows', u'Windows Mobile', u'Windows XP',
-    u'Windows ME', u'Windows 2000', u'Windows NT 4.0',
-    u'Windows CE', u'Windows 95', u'Windows 98',
-    u'Windows 3.1', u'Windows NT'
-]
 
 class HdalabAboutPage(TemplateView):
-    
+
     template_name = "a_propos.html"
-    
+
     def get_context_data(self, **kwargs):
         context = super(HdalabAboutPage, self).get_context_data(**kwargs)
         ua_str = self.request.META.get('HTTP_USER_AGENT', '')
         ua = user_agents.parse(ua_str)
-        if ua.os.family in OLDER_WINDOWS:
-            context['add_kanji_font'] = True
-        else:
-            context['add_kanji_font'] = False
-        
-        if hasattr(settings, 'RENKAN_TUTORIAL_MP4'):
-            context['video_mp4'] = settings.RENKAN_TUTORIAL_MP4
-        if hasattr(settings, 'RENKAN_TUTORIAL_WEBM'):
-            context['video_webm'] = settings.RENKAN_TUTORIAL_WEBM
-        if hasattr(settings, 'RENKAN_TUTORIAL_OGG'):
-            context['video_ogg'] = settings.RENKAN_TUTORIAL_OGG
-        
+        context['add_kanji_font'] = (ua.os.family in settings.OLDER_WINDOWS)
+        context['tutorial_video_urls'] = getattr(settings, 'RENKAN_TUTORIAL_VIDEO_URLS', [])
+
         return context