Merge with tcav
authorhamidouk
Thu, 12 Jan 2012 11:00:10 +0100
changeset 358 27be3fb68776
parent 357 7e234ffc2a23 (current diff)
parent 353 bf08750b894c (diff)
child 359 e8973c3fcc9c
Merge with tcav
src/ldt/ldt/templatetags/str_duration.py
--- a/src/ldt/ldt/ldt_utils/templates/front/front_group.html	Thu Jan 12 10:19:47 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/templates/front/front_group.html	Thu Jan 12 11:00:10 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 %}
 
--- a/src/ldt/ldt/ldt_utils/templates/front/front_home.html	Thu Jan 12 10:19:47 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/templates/front/front_home.html	Thu Jan 12 11:00:10 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 %}
--- a/src/ldt/ldt/ldt_utils/templates/front/front_search_results.html	Thu Jan 12 10:19:47 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/templates/front/front_search_results.html	Thu Jan 12 11:00:10 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 @@
                         <h3>{{res.content_title|capfirst}}</h3>
                     </div>
                     <div class="duree_result_media">
-                        <p>{{res.content.duration}}</p>
+                        <p>{{res.content.duration|str_duration:"::"}}</p>
                     </div>
                     <div class="graphe_result_media">
                         <img src="img/placeholder_media_graph.png" width="340" height="25" alt="graph de volume" />
@@ -62,11 +62,11 @@
                         <div class="left_segment">
                             <div class="color_zone" style="background: #f49af5;"></div>
                             <a href="{% url ldt.ldt_utils.views.lignesdetemps.index_segment segment.project_id segment.iri_id segment.ensemble_id segment.decoupage_id segment.element_id %}"><img src="{{LDT_MEDIA_PREFIX}}img/annot_icon_80x45.png" width="80" height="45" /></a>
-                            <p class="duree_segment">{{ segment.duration }}</p>
+                            <!--p class="duree_segment">{{ segment.duration|str_duration:"::" }}</p-->
                         </div>
                         <h4 class="title_segment"><a class="blue under" href="{% url ldt.ldt_utils.views.lignesdetemps.index_segment segment.project_id segment.iri_id segment.ensemble_id segment.decoupage_id segment.element_id %}">
                           {% if segment.title %}{{ segment.title }}{% else %}{% trans "No title" %}{% endif %}</a></h4>
-                        <p class="text_segment">{% if segment.context %}{{ segment.context }}{% endif %}<br/>begin : {{ segment.begin|str_duration:"::" }} - dur : {{ segment.duration|str_duration:"::" }}</h4>
+                        <p class="text_segment">{% if segment.context %}{{ segment.context }}{% endif %}<br/>{% trans "Begin" %} : {{ segment.begin|str_duration:"::" }} - {% trans "duration" %} : {{ segment.duration|str_duration:"::" }}</h4>
                     </li>
 	                <!--li class="segmentinfos" ><span  class="" title="{% trans 'open ldt' %}"><a class="ldt_link_open_ldt" href="{% url ldt.ldt_utils.views.lignesdetemps.index_segment segment.project_id segment.iri_id segment.ensemble_id segment.decoupage_id segment.element_id %}"-->
 	                </li>
@@ -81,15 +81,26 @@
             <p>
             {% if results.has_previous %}
 	            <a class="blue under" href="{% url ldt.ldt_utils.views.front.search_listing %}?page={{ results.previous_page_number }}">{% trans "previous" %}</a>
+	            .
 	        {% endif %}
-	        
 	        {% if results.paginator.num_pages > 1 %}
 	        <span class="current">
-	           {% 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 %}
+	            <span class="current">
+	                {% if i|add:'1' == results.number %}
+	                <span class="pink">{{i|add:'1'}}</span>
+	                {% else %}
+	                <a class="blue under" href="{% url ldt.ldt_utils.views.front.search_listing %}?page={{i|add:'1'}}">{{i|add:'1'}}</a>
+	                {% endif %}
+	                {% if i|add:'1' < results.paginator.num_pages and 1 < results.paginator.num_pages %}
+	                .
+                    {% endif %}
+	            </span>
+	            {% endfor %}
 	        </span>
 	        {% endif %}
-	
 	        {% if results.has_next %}
+	            .
 	            <a class="blue under" href="{% url ldt.ldt_utils.views.front.search_listing %}?page={{ results.next_page_number }}">{% trans "next" %}</a>
 	        {% endif %}
             </p>
--- a/src/ldt/ldt/static/ldt/css/front_search.css	Thu Jan 12 10:19:47 2012 +0100
+++ b/src/ldt/ldt/static/ldt/css/front_search.css	Thu Jan 12 11:00:10 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 {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ldt/ldt/templatetags/front_tags.py	Thu Jan 12 11:00:10 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)
--- a/src/ldt/ldt/templatetags/str_duration.py	Thu Jan 12 10:19:47 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