]> git.parisson.com Git - mezzo.git/commitdiff
Event date : request optimization + home display
authorEmilie <zawadzki@ircam.fr>
Thu, 17 Nov 2016 16:42:58 +0000 (17:42 +0100)
committerEmilie <zawadzki@ircam.fr>
Thu, 17 Nov 2016 16:42:58 +0000 (17:42 +0100)
app/organization/formats/en/formats.py
app/organization/formats/formats.py [deleted file]
app/templates/agenda/includes/event_date.html
app/templates/agenda/includes/event_date_slider.html [new file with mode: 0644]
app/templates/home/inc/slider.html

index 565a99d59f85eb64741fd210b5cfddabc9e6229f..be26f313e0101faec05ad4c4f1735d62fad58079 100644 (file)
@@ -7,7 +7,7 @@ from __future__ import unicode_literals
 # see http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
 DATE_FORMAT = 'N j, Y'
 DATE_EVENT_FORMAT = 'F j'
-WEEK_DAY_FORMAT = 'D, jS'
+WEEK_DAY_FORMAT = 'F j'
 TIME_FORMAT = 'P'
 DATETIME_FORMAT = 'N j, Y, P'
 YEAR_MONTH_FORMAT = 'F Y'
diff --git a/app/organization/formats/formats.py b/app/organization/formats/formats.py
deleted file mode 100644 (file)
index 016adb4..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-from __future__ import unicode_literals
-
-TIME_FORMAT = 'H\hi'
index 6230768a38ff0704f34d8a5814d9b12ceae989a3..2bc6c0f50b4a12e147730ab3b6446bc5b7e56ae8 100644 (file)
@@ -1,4 +1,5 @@
 {% load event_tags pages_tags mezzanine_tags organization_tags i18n  %}
+{% with event.periods.all as periods %}
     <!-- Start date only  -->
     {% if event.start and not event.end %}
         {{ event.start|date:"DATE_EVENT_FORMAT" }},<br>
@@ -10,7 +11,7 @@
     {% else %}
         <!-- Start and end date is the same day  -->
         {% if event.start|date:"d.m.y" == event.end|date:"d.m.y" %}
-            {% if not event.periods.all %}
+            {% if not periods %}
                 {{ event.start|date:"DATE_EVENT_FORMAT" }},<br>
                 <!-- Start date with hour  -->
                 {% if event.end and event.end|date:"H:i" != "23:59" %}
                 {% endif %}
             {% else %}
                 {{ event.start|date:"DATE_EVENT_FORMAT" }},<br>
-                {% for period in event.periods.all %}
+                {% for period in periods %}
                     {% if period.date_to and period.date_to|date:"H:i" != "23:59" %}
                         {{ period.date_from|time:"TIME_FORMAT" }} - {{ period.date_to|time:"TIME_FORMAT" }}
                     {% else %}
-                        {% if forloop.last or event.periods.all|length == 2 %} {% trans "and"%} {% elif not forloop.first %}, {% endif %}
+                        {% if forloop.last or periods|length == 2 %} {% trans "and"%} {% elif not forloop.first %}, {% endif %}
                         {{ period.date_from|time:"TIME_FORMAT" }}
                     {% endif %}
                 {% endfor %}
 
         <!-- Start and end date are the same month  -->
         {% elif event.start|date:"m.y" == event.end|date:"m.y" %}
-          {% if event.periods.all %}
-            {% with event.periods.all|same_time_in_periods as same_time_in_periods %}
-            {% for period in event.periods.all %}
+          {% if periods %}
+            {% with periods|same_time_in_periods as same_time_in_periods %}
+            {% for period in periods %}
                 {% if period.date_to and period.date_to|date:"H:i" != "23:59" %}
-                    {{ period.date_from|date:"DATE_EVENT_FORMAT" }},<br>
+                    {{ period.date_from|date:"WEEK_DAY_FORMAT" }},<br>
                     {% if period|period_is_more_than_hours:4 %}
                         {{ period.date_from|time:"DATE_EVENT_FORMAT" }} {% trans "through" %} {{ period.date_to|time:"TIME_FORMAT" }}
                     {% else %}
                         {{ period.date_from|time:"TIME_FORMAT" }}
                     {% endif %}
                 {% else %}
-                    {% if event.periods.all|length > 1 and not forloop.last %}
-                        {{ period.date_from|date:"DATE_EVENT_FORMAT" }}{% if event.periods.all|length == 2 %} {% trans "and" %} {% else %},{% endif %}
+                    {% if periods|length > 1 and not forloop.last %}
+                        {{ period.date_from|date:"WEEK_DAY_FORMAT" }}{% if periods|length == 2 %} {% trans "and" %} {% else %},{% endif %}
                     {% else %}
-                        {{ period.date_from|date:"DATE_EVENT_FORMAT" }},
-                        {% if event.periods.all|length > 1 and forloop.first %}{% trans "and" %}{% endif %}
+                        {{ period.date_from|date:"WEEK_DAY_FORMAT" }},
+                        {% if periods|length > 1 and forloop.first %}{% trans "and" %}{% endif %}
                     {% endif %}
                     {% if same_time_in_periods and forloop.last %}
                         {{ period.date_from|time:"TIME_FORMAT" }}
@@ -59,7 +60,7 @@
             {% endfor %}
             {% endwith %}
           {% else %}
-            {{ event.start|date:"DATE_EVENT_FORMAT" }}
+            {{ event.start|date:"WEEK_DAY_FORMAT" }}
             {% if event.end|subtract:event.start|get_attr:"days" > 1 %}
                 {% trans "through" %}
             {% else %}
@@ -79,3 +80,4 @@
         {% endif %}
 
     {% endif %}
+{% endwith %}
diff --git a/app/templates/agenda/includes/event_date_slider.html b/app/templates/agenda/includes/event_date_slider.html
new file mode 100644 (file)
index 0000000..6a41de2
--- /dev/null
@@ -0,0 +1,54 @@
+{% load event_tags pages_tags mezzanine_tags organization_tags i18n  %}
+{% with event.periods.all as periods %}
+    <!-- Start date only  -->
+    {% if event.start and not event.end %}
+        {{ event.start|date:"DATE_EVENT_FORMAT" }},<br>
+        <!-- Start date with hour  -->
+        {% if event.start and event.start|date:"H:i" != "23:59" %}
+            {{ event.start|time:"TIME_FORMAT" }}
+        {% endif %}
+    <!-- Start and end date  -->
+    {% else %}
+        <!-- Start and end date is the same day  -->
+        {% if event.start|date:"d.m.y" == event.end|date:"d.m.y" %}
+            {% if not periods %}
+                {{ event.start|date:"DATE_EVENT_FORMAT" }},<br>
+                <!-- Start date with hour  -->
+                {% if event.end and event.end|date:"H:i" != "23:59" %}
+                    {{ event.start|time:"TIME_FORMAT" }} - {{ event.end|time:"TIME_FORMAT" }}
+                {% else %}
+                    {{ event.start|time:"TIME_FORMAT" }}
+                {% endif %}
+            {% else %}
+                {{ event.start|date:"DATE_EVENT_FORMAT" }},<br>
+                {% for period in periods %}
+                    {% if period.date_to and period.date_to|date:"H:i" != "23:59" %}
+                        {{ period.date_from|time:"TIME_FORMAT" }} - {{ period.date_to|time:"TIME_FORMAT" }}
+                    {% else %}
+                        {% if forloop.last or periods|length == 2 %} {% trans "and"%} {% elif not forloop.first %}, {% endif %}
+                        {{ period.date_from|time:"TIME_FORMAT" }}
+                    {% endif %}
+                {% endfor %}
+            {% endif %}
+        <!-- Start and end date are the same month  -->
+        {% elif event.start|date:"m.y" == event.end|date:"m.y" %}
+            {{ event.start|date:"WEEK_DAY_FORMAT" }}
+            {% if event.end|subtract:event.start|get_attr:"days" > 1 %}
+                {% trans "through" %}
+            {% else %}
+                {% trans "and" %}
+            {% endif %}
+            {{ event.end|date:"DATE_EVENT_FORMAT" }}
+        <!-- Start and end date are completely different  -->
+        {% else %}
+            {{ event.start|date:"DATE_EVENT_FORMAT" }} {% trans "through" %} {{ event.end|date:"DATE_EVENT_FORMAT" }},<br>
+            <!-- Start date with hour  -->
+            {% if event.end and event.end|date:"H:i" != "23:59" %}
+                {{ event.start|time:"TIME_FORMAT" }} - {{ event.end|time:"TIME_FORMAT" }}
+            {% else %}
+                {{ event.start|time:"TIME_FORMAT" }}
+            {% endif %}
+        {% endif %}
+
+    {% endif %}
+{% endwith %}
index 2684d1fc32122cb50de75d94813f543379a39cbe..ff635563b1209aaafa4f9cb6905c7278dd39ef0c 100644 (file)
@@ -45,7 +45,7 @@
                                                                 {% if slider.content_object.sub_title %}
                                                                     <br />
                                                                 {% endif %}
-                                                                {% include 'agenda/includes/event_date.html' %}
+                                                                {% include 'agenda/includes/event_date_slider.html' %}
                                                             {% endwith %}
                                                         {% endif %}
                                                         {% if slider.content_object.location %}