On sépare en plusieurs fichiers les événements, c'est plus lisible

This commit is contained in:
Jean-Marie Favreau 2023-11-11 13:52:43 +01:00
parent 7097aa17d3
commit f50c9b47ac
12 changed files with 269 additions and 179 deletions

View File

@ -57,7 +57,7 @@
{% endif %}
{{ event|picto_status }} <a href="{{ daytag }}" data-target="event-{{ event.id }}" onClick="toggleModal(event)">{{ event.title }}</a>
<dialog id="event-{{ event.id }}">
{% include "agenda_culturel/event-inc.html" with event=event display="modal" close_button=1 filter=filter %}
{% include "agenda_culturel/single-event/event-modal-inc.html" with event=event filter=filter %}
</dialog>
</li>
{% endfor %}

View File

@ -1,155 +0,0 @@
{% load static %}
{% load cat_extra %}
{% load utils_extra %}
{% load event_extra %}
{% load tag_extra %}
<article>
{% if display in "in list by day" %}
{% if display == "in list by day" and event|can_show_start_time %}
<article class='ephemeris-hour'>
{% if event.start_time %}
{% if display == "in list" %}<footer>{% endif %}
<span class="large">{{ event.start_time }}</span>
{% if display == "in list" %}</footer>{% endif %}
{% endif %}
</article>
{% endif %}
{% if display == "in list" %}
{% include "agenda_culturel/ephemeris-inc.html" with event=event filter=filter %}
{% endif %}
{{ event.category | small_cat }}
{% if event.location %}<hgroup>{% endif %}
{% if display == "in list" %}<h2>{% else %}<h3>{% endif %}
{{ event|picto_status }}
<a href="{{ event.get_absolute_url }}">{{ event.title }}</a>
{% if display == "in list" %}</h2>{% else %}</h3>{% endif %}
{% if event.location %}
{% if display == "in list" %}<h3>{% else %}<h4>{% endif %}
<svg width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<use href="{% static 'images/feather-sprite.svg' %}#map-pin" />
</svg>
{{ event.location }}
{% if display == "in list" %}</h3>{% else %}</h4>{% endif %}
</hgroup>
{% endif %}
{% if event|need_complete_display:display %}<p>
<svg width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<use href="{% static 'images/feather-sprite.svg' %}#calendar" />
</svg>
<em>{% if event.end_day %}Cet événement dure du {% else %}Cet événement a lieu le{% endif %}
{% include "agenda_culturel/date-times-inc.html" with event=event %}
</em></p>
{% endif %}
{% elif display == "modal" %}
<header>
<a href="#event-{{ event.id }}"
aria-label="Fermer"
class="close"
data-target="event-{{ event.id }}"
onClick="toggleModal(event)"></a>
<h3>{{ event.category | small_cat }} {{ event|picto_status }} {{ event.title }}</h3>
<p>
<svg width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<use href="{% static 'images/feather-sprite.svg' %}#map-pin" />
</svg>
{{ event.location }}
</p>
<p><svg width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<use href="{% static 'images/feather-sprite.svg' %}#calendar" />
</svg>
{% if event.end_day %}du{% else %}le{% endif %}
{% include "agenda_culturel/date-times-inc.html" with event=event %}
</p>
</header>
{% else %}
<header>
{% include "agenda_culturel/ephemeris-inc.html" with event=event filter=filter %}
{{ event.category | small_cat }}
<h1>{{ event|picto_status }} {{ event.title }}</h1>
<p><svg width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<use href="{% static 'images/feather-sprite.svg' %}#calendar" />
</svg>
{% if event.end_day %}du{% else %}le{% endif %}
{% include "agenda_culturel/date-times-inc.html" with event=event %}
</p>
<p>
<svg width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<use href="{% static 'images/feather-sprite.svg' %}#map-pin" />
</svg>
{{ event.location }}
</p>
</header>
{% endif %}
{% if event.image and display != "modal" %}
<article class='illustration{% if display in "in list by day" %}-small{% endif %}'>
<img src="{{ event.image }}" alt="{{ event.image_alt }}" />
</article>
{% endif %}
{% if display in "in list by day" or display == "modal" %}
<p>{{ event.description |truncatewords:20 }}</p>
{% else %}
<p>{{ event.description }}</p>
{% endif %}
{% if display == "modal" %}
<p>
{% for tag in event.tags %}
{{ tag | tag_button }}
{% endfor %}
</p>
<footer class="infos-and-buttons">
<div class="buttons">
<a href="{{ event.get_absolute_url }}" role="button">Voir l'événement <svg width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<use href="{% static 'images/feather-sprite.svg' %}#chevron-right" />
</svg></a>
</div>
</footer>
{% else %}
<footer class="infos-and-buttons">
<div class="infos">
<p>
{% for tag in event.tags %}
<a href="{% url 'view_tag' tag %}" role="button" class="small-cat">{{ tag }}</a>
{% endfor %}
</p>
{% if event.reference_urls %}
{% if display in "in list by day" %}
<p>Source{{ event.reference_urls|pluralize }}&nbsp;:
{% else %}
<p>Cet événement est proposé par&nbsp;:
{% endif %}
{% for eurl in event.reference_urls %}
<a href="{{ eurl }}">{{ eurl|hostname }}</a>{% if not forloop.last %}, {% endif %}
{% endfor %}
</p>
{% else %}
<p><em>Cet événement est disponible uniquement sur les nuits énimagmatiques.</em></p>
{% endif %}
</div>
{% if user.is_authenticated %}
<div class="buttons">
<a href="{% url 'edit_event' event.id %}" role="button">éditer</a>
<a href="{% url 'delete_event' event.id %}" role="button">supprimer</a>
{% if display != "single" %}
<a href="{{ event.get_absolute_url }}" role="button">Voir l'événement <svg width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<use href="{% static 'images/feather-sprite.svg' %}#chevron-right" />
</svg></a>
{% endif %}
</div>
{% endif %}
</footer>
{% endif %}
</article>

View File

@ -34,16 +34,15 @@
<div class="navigation">
<div>
{% with day|shift_day:-1 as pred_day %}
<a role="button" href="{% url 'day_view' pred_day.year pred_day.month pred_day.day %}?{{ filter.get_url }}"><svg width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<use href="{% static 'images/feather-sprite.svg' %}#chevron-left" />
</svg> précédent</a>
<a role="button" href="{% url 'day_view' pred_day.year pred_day.month pred_day.day %}?{{ filter.get_url }}">
{% picto_from_name "chevron-left" %} précédent</a>
{% endwith %}
</div>
<div class="right">
{% with day|shift_day:1 as next_day %}
<a role="button" href="{% url 'day_view' next_day.year next_day.month next_day.day %}?{{ filter.get_url }}">suivant <svg width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<use href="{% static 'images/feather-sprite.svg' %}#chevron-right" />
</svg></a>
<a role="button" href="{% url 'day_view' next_day.year next_day.month next_day.day %}?{{ filter.get_url }}">suivant
{% picto_from_name "chevron-right" %}
</a>
{% endwith %}
</div>
</div>
@ -51,7 +50,7 @@
{% if events %}
{% for event in events %}
{% include "agenda_culturel/event-inc.html" with event=event display="in list by day" filter=filter %}
{% include "agenda_culturel/single-event/event-in-list-by-day-inc.html" with event=event filter=filter %}
{% endfor %}
{% else %}
<article>

View File

@ -10,6 +10,6 @@
{% block content %}
{% include "agenda_culturel/event-inc.html" with event=event display="single" filter=filter %}
{% include "agenda_culturel/single-event/event-single-inc.html" with event=event filter=filter %}
{% endblock %}

View File

@ -33,14 +33,13 @@
<header>
<div class="navigation">
<div>
<a role="button" href="{% url 'month_view' calendar.previous_month.year calendar.previous_month.month %}?{{ filter.get_url }}"><svg width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<use href="{% static 'images/feather-sprite.svg' %}#chevron-left" />
</svg> précédent</a>
<a role="button" href="{% url 'month_view' calendar.previous_month.year calendar.previous_month.month %}?{{ filter.get_url }}">
{% picto_from_name "chevron-left" %} précédent</a>
</div>
<div class="right">
<a role="button" href="{% url 'month_view' calendar.next_month.year calendar.next_month.month %}?{{ filter.get_url }}">suivant <svg width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<use href="{% static 'images/feather-sprite.svg' %}#chevron-right" />
</svg></a>
<a role="button" href="{% url 'month_view' calendar.next_month.year calendar.next_month.month %}?{{ filter.get_url }}">suivant
{% picto_from_name "chevron-right" %}
</a>
</div>
</div>
</header>

View File

@ -42,14 +42,13 @@
<header>
<div class="navigation">
<div>
<a role="button" href="{% url 'week_view' calendar.previous_week.year calendar.previous_week|week %}?{{ filter.get_url }}"><svg width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<use href="{% static 'images/feather-sprite.svg' %}#chevron-left" />
</svg> précédente</a>
<a role="button" href="{% url 'week_view' calendar.previous_week.year calendar.previous_week|week %}?{{ filter.get_url }}">
{% picto_from_name "chevron-left" %} précédente</a>
</div>
<div class="right">
<a role="button" href="{% url 'week_view' calendar.next_week.year calendar.next_week|week %}?{{ filter.get_url }}">suivante <svg width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<use href="{% static 'images/feather-sprite.svg' %}#chevron-right" />
</svg></a>
<a role="button" href="{% url 'week_view' calendar.next_week.year calendar.next_week|week %}?{{ filter.get_url }}">suivante
{% picto_from_name "chevron-right" %}
</a>
</div>
</div>
</header>

View File

@ -0,0 +1,77 @@
{% load static %}
{% load cat_extra %}
{% load utils_extra %}
{% load event_extra %}
{% load tag_extra %}
<article>
{% if event|can_show_start_time %}
<article class='ephemeris-hour'>
{% if event.start_time %}
<span class="large">{{ event.start_time }}</span>
{% endif %}
</article>
{% endif %}
{{ event.category | small_cat }}
{% if event.location %}<hgroup>{% endif %}
<h3>
{{ event|picto_status }}
<a href="{{ event.get_absolute_url }}">{{ event.title }}</a></h3>
{% if event.location %}
<h4>
{% picto_from_name "map-pin" %}
{{ event.location }}
</h4>
</hgroup>
{% endif %}
{% if event|need_complete_display:true %}<p>
{% picto_from_name "calendar" %}
<em>{% if event.end_day %}Cet événement dure du {% else %}Cet événement a lieu le{% endif %}
{% include "agenda_culturel/date-times-inc.html" with event=event %}
</em></p>
{% endif %}
{% if event.image %}
<article class='illustration-small'>
<img src="{{ event.image }}" alt="{{ event.image_alt }}" />
</article>
{% endif %}
<p>{{ event.description |truncatewords:20 }}</p>
<footer class="infos-and-buttons">
<div class="infos">
<p>
{% for tag in event.tags %}
<a href="{% url 'view_tag' tag %}" role="button" class="small-cat">{{ tag }}</a>
{% endfor %}
</p>
{% if event.reference_urls %}
<p>Source{{ event.reference_urls|pluralize }}&nbsp;:
{% for eurl in event.reference_urls %}
<a href="{{ eurl }}">{{ eurl|hostname }}</a>{% if not forloop.last %}, {% endif %}
{% endfor %}
</p>
{% else %}
<p><em>Cet événement est disponible uniquement sur les nuits énimagmatiques.</em></p>
{% endif %}
</div>
{% if user.is_authenticated %}
<div class="buttons">
<a href="{% url 'edit_event' event.id %}" role="button">éditer</a>
<a href="{% url 'delete_event' event.id %}" role="button">supprimer</a>
<a href="{{ event.get_absolute_url }}" role="button">Voir l'événement <svg width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<use href="{% static 'images/feather-sprite.svg' %}#chevron-right" />
</svg></a>
</div>
{% endif %}
</footer>
</article>

View File

@ -0,0 +1,71 @@
{% load static %}
{% load cat_extra %}
{% load utils_extra %}
{% load event_extra %}
{% load tag_extra %}
<article>
{% include "agenda_culturel/ephemeris-inc.html" with event=event filter=filter %}
{{ event.category | small_cat }}
{% if event.location %}<hgroup>{% endif %}
<h2>
{{ event|picto_status }}
<a href="{{ event.get_absolute_url }}">{{ event.title }}</a>
</h2>
{% if event.location %}
<h3>
{% picto_from_name "map-pin" %}
{{ event.location }}
</h3>
</hgroup>
{% endif %}
{% if event|need_complete_display:false %}<p>
{% picto_from_name "calendar" %}
<em>{% if event.end_day %}Cet événement dure du {% else %}Cet événement a lieu le{% endif %}
{% include "agenda_culturel/date-times-inc.html" with event=event %}
</em></p>
{% endif %}
{% if event.image %}
<article class='illustration{% if display in "in list by day" %}-small{% endif %}'>
<img src="{{ event.image }}" alt="{{ event.image_alt }}" />
</article>
{% endif %}
<p>{{ event.description |truncatewords:20 }}</p>
<footer class="infos-and-buttons">
<div class="infos">
<p>
{% for tag in event.tags %}
<a href="{% url 'view_tag' tag %}" role="button" class="small-cat">{{ tag }}</a>
{% endfor %}
</p>
{% if event.reference_urls %}
<p>Source{{ event.reference_urls|pluralize }}&nbsp;:
{% for eurl in event.reference_urls %}
<a href="{{ eurl }}">{{ eurl|hostname }}</a>{% if not forloop.last %}, {% endif %}
{% endfor %}
</p>
{% else %}
<p><em>Cet événement est disponible uniquement sur les nuits énimagmatiques.</em></p>
{% endif %}
</div>
{% if user.is_authenticated %}
<div class="buttons">
<a href="{% url 'edit_event' event.id %}" role="button">éditer</a>
<a href="{% url 'delete_event' event.id %}" role="button">supprimer</a>
<a href="{{ event.get_absolute_url }}" role="button">Voir l'événement <svg width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<use href="{% static 'images/feather-sprite.svg' %}#chevron-right" />
</svg></a>
</div>
{% endif %}
</footer>
{% endif %}
</article>

View File

@ -0,0 +1,44 @@
{% load static %}
{% load cat_extra %}
{% load utils_extra %}
{% load event_extra %}
{% load tag_extra %}
<article>
<header>
<a href="#event-{{ event.id }}"
aria-label="Fermer"
class="close"
data-target="event-{{ event.id }}"
onClick="toggleModal(event)"></a>
<h3>{{ event.category | small_cat }} {{ event|picto_status }} {{ event.title }}</h3>
<p>
{% picto_from_name "map-pin" %}
{{ event.location }}
</p>
<p>
{% picto_from_name "calendar" %}
{% if event.end_day %}du{% else %}le{% endif %}
{% include "agenda_culturel/date-times-inc.html" with event=event %}
</p>
</header>
<p>{{ event.description |truncatewords:20 }}</p>
<p>
{% for tag in event.tags %}
{{ tag | tag_button }}
{% endfor %}
</p>
<footer class="infos-and-buttons">
<div class="buttons">
<a href="{{ event.get_absolute_url }}" role="button">Voir l'événement <svg width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<use href="{% static 'images/feather-sprite.svg' %}#chevron-right" />
</svg></a>
</div>
</footer>
</article>

View File

@ -0,0 +1,56 @@
{% load static %}
{% load cat_extra %}
{% load utils_extra %}
{% load event_extra %}
{% load tag_extra %}
<article>
<header>
{% include "agenda_culturel/ephemeris-inc.html" with event=event filter=filter %}
{{ event.category | small_cat }}
<h1>{{ event|picto_status }} {{ event.title }}</h1>
{% picto_from_name "calendar" %}
{% if event.end_day %}du{% else %}le{% endif %}
{% include "agenda_culturel/date-times-inc.html" with event=event %}
</p>
<p>
{% picto_from_name "map-pin" %}
{{ event.location }}
</p>
</header>
{% if event.image %}
<article class='illustration{% if display in "in list by day" %}-small{% endif %}'>
<img src="{{ event.image }}" alt="{{ event.image_alt }}" />
</article>
{% endif %}
<p>{{ event.description }}</p>
<footer class="infos-and-buttons">
<div class="infos">
<p>
{% for tag in event.tags %}
<a href="{% url 'view_tag' tag %}" role="button" class="small-cat">{{ tag }}</a>
{% endfor %}
</p>
{% if event.reference_urls %}
<p>Cet événement est proposé par&nbsp;:
{% for eurl in event.reference_urls %}
<a href="{{ eurl }}">{{ eurl|hostname }}</a>{% if not forloop.last %}, {% endif %}
{% endfor %}
</p>
{% else %}
<p><em>Cet événement est disponible uniquement sur les nuits énimagmatiques.</em></p>
{% endif %}
</div>
{% if user.is_authenticated %}
<div class="buttons">
<a href="{% url 'edit_event' event.id %}" role="button">éditer</a>
<a href="{% url 'delete_event' event.id %}" role="button">supprimer</a>
</div>
{% endif %}
</footer>
</article>

View File

@ -14,6 +14,6 @@
<h1>Les événements <em>{{ tag }}</em></h1>
{% for event in events %}
{% include "agenda_culturel/event-inc.html" with event=event display="in list" %}
{% include "agenda_culturel/single-event/event-in-list-inc.html" with event=event %}
{% endfor %}
{% endblock %}

View File

@ -22,8 +22,8 @@ def can_show_start_time(event):
@register.filter
def need_complete_display(event, display):
return event.end_day and event.end_day != event.start_day and (event.start_time or event.end_time or display == "in list by day")
def need_complete_display(event, display_full):
return event.end_day and event.end_day != event.start_day and (event.start_time or event.end_time or display_full)
@register.filter