From: Emilie Date: Thu, 17 Nov 2016 16:42:58 +0000 (+0100) Subject: Event date : request optimization + home display X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=5c0a4ebfc49945e50c20141960b60143ac0703a8;p=mezzo.git Event date : request optimization + home display --- diff --git a/app/organization/formats/en/formats.py b/app/organization/formats/en/formats.py index 565a99d5..be26f313 100644 --- a/app/organization/formats/en/formats.py +++ b/app/organization/formats/en/formats.py @@ -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 index 016adb48..00000000 --- a/app/organization/formats/formats.py +++ /dev/null @@ -1,3 +0,0 @@ -from __future__ import unicode_literals - -TIME_FORMAT = 'H\hi' diff --git a/app/templates/agenda/includes/event_date.html b/app/templates/agenda/includes/event_date.html index 6230768a..2bc6c0f5 100644 --- a/app/templates/agenda/includes/event_date.html +++ b/app/templates/agenda/includes/event_date.html @@ -1,4 +1,5 @@ {% load event_tags pages_tags mezzanine_tags organization_tags i18n %} +{% with event.periods.all as periods %} {% if event.start and not event.end %} {{ event.start|date:"DATE_EVENT_FORMAT" }},
@@ -10,7 +11,7 @@ {% else %} {% 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" }},
{% if event.end and event.end|date:"H:i" != "23:59" %} @@ -20,11 +21,11 @@ {% endif %} {% else %} {{ event.start|date:"DATE_EVENT_FORMAT" }},
- {% 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 %} @@ -32,22 +33,22 @@ {% 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" }},
+ {{ period.date_from|date:"WEEK_DAY_FORMAT" }},
{% 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 index 00000000..6a41de20 --- /dev/null +++ b/app/templates/agenda/includes/event_date_slider.html @@ -0,0 +1,54 @@ +{% load event_tags pages_tags mezzanine_tags organization_tags i18n %} +{% with event.periods.all as periods %} + + {% if event.start and not event.end %} + {{ event.start|date:"DATE_EVENT_FORMAT" }},
+ + {% if event.start and event.start|date:"H:i" != "23:59" %} + {{ event.start|time:"TIME_FORMAT" }} + {% endif %} + + {% else %} + + {% if event.start|date:"d.m.y" == event.end|date:"d.m.y" %} + {% if not periods %} + {{ event.start|date:"DATE_EVENT_FORMAT" }},
+ + {% 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" }},
+ {% 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 %} + + {% 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" }} + + {% else %} + {{ event.start|date:"DATE_EVENT_FORMAT" }} {% trans "through" %} {{ event.end|date:"DATE_EVENT_FORMAT" }},
+ + {% 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 %} diff --git a/app/templates/home/inc/slider.html b/app/templates/home/inc/slider.html index 2684d1fc..ff635563 100644 --- a/app/templates/home/inc/slider.html +++ b/app/templates/home/inc/slider.html @@ -45,7 +45,7 @@ {% if slider.content_object.sub_title %}
{% endif %} - {% include 'agenda/includes/event_date.html' %} + {% include 'agenda/includes/event_date_slider.html' %} {% endwith %} {% endif %} {% if slider.content_object.location %}