# HG changeset patch # User cavaliet # Date 1326361648 -3600 # Node ID bf08750b894c65cb345325ed84204f9749b07c37 # Parent 6fa2e1f8ddaad3534eee40e8faa11129a8fef398 Update search and front search template. Add tag filter for duration presentation. diff -r 6fa2e1f8ddaa -r bf08750b894c src/ldt/ldt/ldt_utils/templates/front/front_group.html --- a/src/ldt/ldt/ldt_utils/templates/front/front_group.html Thu Jan 12 10:13:00 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/templates/front/front_group.html Thu Jan 12 10:47:28 2012 +0100 @@ -1,7 +1,7 @@ {% extends "front/front_base.html" %} {% load i18n %} {% load thumbnail %} -{% load str_duration %} +{% load front_tags %} {% block title %}Lignes de temps : groupe "{{group.name}}"{% endblock %} diff -r 6fa2e1f8ddaa -r bf08750b894c src/ldt/ldt/ldt_utils/templates/front/front_home.html --- a/src/ldt/ldt/ldt_utils/templates/front/front_home.html Thu Jan 12 10:13:00 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/templates/front/front_home.html Thu Jan 12 10:47:28 2012 +0100 @@ -1,7 +1,7 @@ {% extends "front/front_base.html" %} {% load i18n %} {% load thumbnail %} -{% load str_duration %} +{% load front_tags %} {% block title %}Lignes de temps : Home{% endblock %} diff -r 6fa2e1f8ddaa -r bf08750b894c src/ldt/ldt/ldt_utils/templates/front/front_search_results.html --- a/src/ldt/ldt/ldt_utils/templates/front/front_search_results.html Thu Jan 12 10:13:00 2012 +0100 +++ b/src/ldt/ldt/ldt_utils/templates/front/front_search_results.html Thu Jan 12 10:47:28 2012 +0100 @@ -1,7 +1,7 @@ {% extends "front/front_base.html" %} {% load i18n %} {% load thumbnail %} -{% load str_duration %} +{% load front_tags %} {% block title %}Lignes de temps : {% trans 'search' %} ""{% endblock %} @@ -48,7 +48,7 @@

{{res.content_title|capfirst}}

-

{{res.content.duration}}

+

{{res.content.duration|str_duration:"::"}}

graph de volume @@ -62,11 +62,11 @@
-

{{ segment.duration }}

+

{% if segment.title %}{{ segment.title }}{% else %}{% trans "No title" %}{% endif %}

-

{% if segment.context %}{{ segment.context }}{% endif %}
begin : {{ segment.begin|str_duration:"::" }} - dur : {{ segment.duration|str_duration:"::" }} +

{% if segment.context %}{{ segment.context }}{% endif %}
{% trans "Begin" %} : {{ segment.begin|str_duration:"::" }} - {% trans "duration" %} : {{ segment.duration|str_duration:"::" }} @@ -81,15 +81,26 @@

{% if results.has_previous %} {% trans "previous" %} + . {% endif %} - {% if results.paginator.num_pages > 1 %} - {% blocktrans with number=results.number num_pages=results.paginator.num_pages%}Page {{number}} of {{num_pages}}{% endblocktrans %} + {% for i in results.paginator.num_pages|get_range %} + + {% if i|add:'1' == results.number %} + {{i|add:'1'}} + {% else %} + {{i|add:'1'}} + {% endif %} + {% if i|add:'1' < results.paginator.num_pages and 1 < results.paginator.num_pages %} + . + {% endif %} + + {% endfor %} {% endif %} - {% if results.has_next %} + . {% trans "next" %} {% endif %}

diff -r 6fa2e1f8ddaa -r bf08750b894c src/ldt/ldt/static/ldt/css/front_search.css --- a/src/ldt/ldt/static/ldt/css/front_search.css Thu Jan 12 10:13:00 2012 +0100 +++ b/src/ldt/ldt/static/ldt/css/front_search.css Thu Jan 12 10:47:28 2012 +0100 @@ -86,7 +86,7 @@ } p.duree_segment { - position: absolute; margin: 0; right: 10px; bottom: 10px; color: #ffffff; font-size: 11px; + position: absolute; margin: 0; right: 10px; bottom: 10px; color: #ffffff; font-size: 11px; text-shadow:1px 1px 1px #000000; } div.color_zone { diff -r 6fa2e1f8ddaa -r bf08750b894c src/ldt/ldt/templatetags/front_tags.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ldt/ldt/templatetags/front_tags.py Thu Jan 12 10:47:28 2012 +0100 @@ -0,0 +1,50 @@ +from django.template import Library, TemplateSyntaxError + +register = Library() + +@register.filter +def str_duration(value, arg=None): + """Takes an integer value of milliseconds and write a human readable duration like 1h23, 01:23 (hours:minutes), 01:23:45 (hours:minutes:seconds), or number of seconds """ + # Error management + if value is None : + return "" + if not isinstance(value, (int,long,float,str,unicode)) : + raise TemplateSyntaxError('str_duration value error : value must be integer or long or float or string. type = ' + str(type(value))) + if isinstance(value, (str,unicode)) : + try: + value = int(value) + except : + raise TemplateSyntaxError('str_duration value error : can not convert value "' + value + '" into integer') + # We take off the milliseconds + ms = abs(value) + sec = ms//1000 + if arg is None : + arg = "::" + if arg=="::" or arg=="h" or arg==":" : + hours = sec//3600 + min = (sec - (hours * 3600))//60 + if min<10: + min_str = "0" + str(min) + else: + min_str = str(min) + if (arg=="::" or arg==":") and hours<10 : + hours_str = "0" + str(hours) + else : + hours_str = str(hours) + if arg=="h" or arg==":" : + return hours_str + arg + min_str + sec = (sec - (hours * 3600) - (min*60)) + if sec<10: + sec_str = "0" + str(sec) + else: + sec_str = str(sec) + return hours_str + ":" + min_str + ":" + sec_str + elif arg=="s" : + return sec + else : + raise TemplateSyntaxError('str_duration filter error : filters argument must be None, "::", ":", "h" or "s"') +str_duration.is_safe = True + +@register.filter +def get_range(value): + return range(value) diff -r 6fa2e1f8ddaa -r bf08750b894c src/ldt/ldt/templatetags/str_duration.py --- a/src/ldt/ldt/templatetags/str_duration.py Thu Jan 12 10:13:00 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -from django.template import Library, TemplateSyntaxError - -register = Library() - -@register.filter -def str_duration(value, arg=None): - """Takes an integer value of milliseconds and write a human readable duration like 1h23, 01:23 (hours:minutes), 01:23:45 (hours:minutes:seconds), or number of seconds """ - # Error management - if value is None : - return "" - if not isinstance(value, (int,long,float,str,unicode)) : - raise TemplateSyntaxError('str_duration value error : value must be integer or long or float or string. type = ' + str(type(value))) - if isinstance(value, (str,unicode)) : - try: - value = int(value) - except : - raise TemplateSyntaxError('str_duration value error : can not convert value "' + value + '" into integer') - # We take off the milliseconds - ms = abs(value) - sec = ms//1000 - if arg is None : - arg = "::" - if arg=="::" or arg=="h" or arg==":" : - hours = sec//3600 - min = (sec - (hours * 3600))//60 - if min<10: - min_str = "0" + str(min) - else: - min_str = str(min) - if (arg=="::" or arg==":") and hours<10 : - hours_str = "0" + str(hours) - else : - hours_str = str(hours) - if arg=="h" or arg==":" : - return hours_str + arg + min_str - sec = (sec - (hours * 3600) - (min*60)) - if sec<10: - sec_str = "0" + str(sec) - else: - sec_str = str(sec) - return hours_str + ":" + min_str + ":" + sec_str - elif arg=="s" : - return sec - else : - raise TemplateSyntaxError('str_duration filter error : filters argument must be None, "::", ":", "h" or "s"') -str_duration.is_safe = True