]> git.parisson.com Git - mezzo.git/commitdiff
Add the event date specific formats
authorJérémy Fabre <Jeremy@iMac-de-Jeremy.local>
Mon, 26 Sep 2016 08:44:26 +0000 (10:44 +0200)
committerJérémy Fabre <Jeremy@iMac-de-Jeremy.local>
Mon, 26 Sep 2016 08:44:26 +0000 (10:44 +0200)
app/templates/agenda/includes/event_date.html [new file with mode: 0644]
app/templates/core/inc/generic_card.html
app/templates/home/inc/slider.html

diff --git a/app/templates/agenda/includes/event_date.html b/app/templates/agenda/includes/event_date.html
new file mode 100644 (file)
index 0000000..9bbb710
--- /dev/null
@@ -0,0 +1,49 @@
+{% load i18n %}
+
+<!-- Start date only  -->
+{% if event.start and not event.end %}
+
+    {{ event.start|date:"l j F" }}
+
+    <!-- Start date with hour  -->
+    {% if event.start|date:"H:i" != "23:59" %}
+        {% trans "at" %}
+        {{ event.start|date:"H\hi" }}
+    {% 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" %}
+
+        {{ event.start|date:"l j F" }}
+
+        <!-- Start date with hour  -->
+        {% if event.start|date:"H:i" != "23:59" %}
+            {% trans "from" %}
+            {{ event.start|date:"H\hi" }}
+            {% if event.end|date:"H:i" != "23:59" %}
+                {% trans "to" %}
+                {{ event.end|date:"H\hi" }}
+            {% endif %}
+        {% endif %}
+
+    <!-- Start and end date are the same month  -->
+    {% elif event.start|date:"m.y" == event.end|date:"m.y" %}
+
+        {% trans "From" %}
+        {{ event.start|date:"j" }}
+        {% trans "to" %}
+        {{ event.end|date:"j F" }}
+
+    <!-- Start and end date are completely different  -->
+    {% else %}
+
+        {{ event.start|date:"j F" }}
+        -
+        {{ event.end|date:"j F" }}
+
+    {% endif %}
+
+{% endif %}
index 3cd991524050d762d11820a4bf9ec0a5a6ae66cd..790a9780a74e471dc305d5ddbf7a77438454af77 100644 (file)
         <h3 class="article-box__title">{{ content.content_object.title }}</h3>
         <div class="article-box__subtitle">
             {% if content.content_type.model == 'article' %}
-                {{ content.content_object.publish_date|date:"DATE_FORMAT" }}
+                {{ content.content_object.publish_date|date:"d.m.y" }}
                 {% for category in content.content_object.categories.all %}
                     {% if forloop.first %} | {% endif %}
                     {% if not forloop.first %}, {% endif %}
                     <strong>{{ category }}</strong>
                 {% endfor %}
             {% elif content.content_type.model == 'event' %}
-                {% if content.content_object.start %}
-                    {% if content.content_object.end %}
-                        {% trans "From" %}
-                    {% endif %}
-                    {{ content.content_object.start|date:"DATE_FORMAT" }}
-                    {% if content.content_object.end %}
-                        {% trans "to" %} {{ content.content_object.end|date:"DATE_FORMAT" }}
-                    {% endif %}
-                {% endif %}
+                {% with content.content_object as event %}
+                    <strong>
+                        {% include 'agenda/includes/event_date.html' %}
+                    </strong>
+                {% endwith %}
                 {% if content.content_object.location %}
-                     <br /><strong>{{ content.content_object.location }}</strong>
+                     <br />{{ content.content_object.location }}
                 {% endif %}
             {% endif %}
         </div>
index acd26a62084e8738babb32ce5bf35ee78f4a0b12..f0031e5c235ca2a329d939583cccfa123db213d4 100644 (file)
                                                     <h3 class="article-box__title">{{ slider.content_object.title }}</h3>
                                                     <div class="article-box__subtitle">
                                                         <strong>{{ slider.content_object.sub_title }}</strong>
-                                                    </div>
-                                                    <div>
                                                         {% if slider.content_object.start %}
-                                                            {% if slider.content_object.end %}
-                                                                {% trans "From" %}
-                                                            {% endif %}
-                                                            {{ slider.content_object.start|date:"DATE_FORMAT" }}
-                                                            {% if slider.content_object.end %}
-                                                                {% trans "to" %} {{ slider.content_object.end|date:"DATE_FORMAT" }}
-                                                            {% endif %}
+                                                            {% with slider.content_object as event %}
+                                                                <strong>
+                                                                    {% include 'agenda/includes/event_date.html' %}
+                                                                </strong>
+                                                            {% endwith %}
                                                         {% endif %}
                                                         {% if slider.content_object.location %}
-                                                             <br /><strong>{{ slider.content_object.location }}</strong>
+                                                             <br />{{ slider.content_object.location }}
                                                         {% endif %}
                                                     </div>
                                                     <div class="article-box__desc">