Amélioration du rendu

This commit is contained in:
Jean-Marie Favreau 2023-11-04 16:17:28 +01:00
parent be7a8de1b1
commit 58e4545ee1
4 changed files with 72 additions and 25 deletions

View File

@ -1,10 +1,37 @@
{% extends "agenda_culturel/page-events.html" %} {% extends "agenda_culturel/page.html" %}
{% block title %}{{ object.title }}{% endblock %} {% block title %}{{ object.title }}{% endblock %}
{% block events %} {% load cat_extra %}
{% block content %}
<article>
<header>
<h1>{{ object.title }}</h1> <h1>{{ object.title }}</h1>
<p>Date&nbsp;: {{ object.start_day }}</p> <ul>
<li>Début&nbsp;: {{ object.start_day }} {% if object.start_time %} à {{ object.start_time }}{% endif %}</li>
{% if object.end_day or object.end_time %}
<li>Fin&nbsp;:
{% if object.end_day %}{{ object.end_day }}{% endif %}
{% if object.end_time %}{{ object.end_time }}{% endif %}
</li>
{% endif %}
</ul>
</header>
<p>{{ event.description }}</p>
<footer>
<p>{{ event.category | small_cat }}</p>
<p>
{% for tag in event.tags %}
<a href="" role="button" class="small-cat">{{ tag }}</a>
{% endfor %}
</p>
</footer>
</article>
{% endblock %} {% endblock %}

View File

@ -3,8 +3,9 @@
{% block title %}Tous les événements{% endblock %} {% block title %}Tous les événements{% endblock %}
{% block content %} {% block content %}
<h1>Derniers événements soumis</h1>
<h1>Derniers événements soumis</h1>
<article>
<details> <details>
<summary>Filtrer et trier</summary> <summary>Filtrer et trier</summary>
<section> <section>
@ -15,28 +16,27 @@
</form> </form>
</section> </section>
</details> </details>
{% for obj in paginator_filter %} {% for obj in paginator_filter %}
{{ obj.title }} <br /> {{ obj.title }} <br />
{% endfor %} {% endfor %}
<div class="pagination"> <footer>
<span class="step-links"> <span>
{% if paginator_filter.has_previous %} {% if paginator_filter.has_previous %}
<a href="?page=1">&laquo; premier</a> <a href="?page=1" role="button">&laquo; premier</a>
<a href="?page={{ paginator_filter.previous_page_number }}">précédent</a> <a href="?page={{ paginator_filter.previous_page_number }}" role="button">précédent</a>
{% endif %} {% endif %}
<span class="current"> <span>
Page {{ paginator_filter.number }} sur {{ paginator_filter.paginator.num_pages }} Page {{ paginator_filter.number }} sur {{ paginator_filter.paginator.num_pages }}
</span> </span>
{% if paginator_filter.has_next %} {% if paginator_filter.has_next %}
<a href="?page={{ paginator_filter.next_page_number }}">suivant</a> <a href="?page={{ paginator_filter.next_page_number }}" role="button">suivant</a>
<a href="?page={{ paginator_filter.paginator.num_pages }}">dernier &raquo;</a> <a href="?page={{ paginator_filter.paginator.num_pages }}" role="button">dernier &raquo;</a>
{% endif %} {% endif %}
</span> </span>
</div> </footer>
</article>
{% endblock %} {% endblock %}

View File

@ -11,6 +11,15 @@
{% css_categories %} {% css_categories %}
{% endblock %} {% endblock %}
{% block title %}
{% if category %}
{{ category.alt_name | capfirst }}
{{ selected_mode }}
{% else %}
{{ selected_mode | capfirst }}
{% endif %}
{% endblock %}
{% block content %} {% block content %}
<details role="list"> <details role="list">
<summary aria-haspopup="listbox" role="button"> <summary aria-haspopup="listbox" role="button">
@ -72,17 +81,26 @@
<h2>{{ date |date:"l j F"| capfirst }}</h2> <h2>{{ date |date:"l j F"| capfirst }}</h2>
{% for event in events_date %} {% for event in events_date %}
<article> <article>
<h3><a href="{{ event.get_absolute_url }}">{{ event.title }}</a></h3> <h3>
{{ event.description }} {% if not event.end_day and event.start_time %}{{ event.start_time }}{% endif %}
<a href="{{ event.get_absolute_url }}">{{ event.title }}</a></h3>
{% if event.end_day %}<p><em>Cet événement dure du {{ event.start_day |date:"l j F" }} au {{ event.end_day |date:"l j F" }}</em></p>{% endif %}
<p>{{ event.description |truncatewords:20 }}</p>
<footer> <footer>
{% if category %} <p>{% if category %}
{{ event.category | small_cat }} {{ event.category | small_cat }}
{% else %} {% else %}
{% url 'view_mode_cat' selected_mode.name event.category.pk as url_cat %} {% url 'view_mode_cat' selected_mode.name event.category.pk as url_cat %}
{{ event.category | small_cat:url_cat }} {{ event.category | small_cat:url_cat }}
{% endif %} {% endif %} </p>
</article> <p>
{% for tag in event.tags %}
<a href="" role="button" class="small-cat">{{ tag }}</a>
{% endfor %}
</p>
</footer> </footer>
</article>
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% endwith %} {% endwith %}

View File

@ -84,8 +84,10 @@ def css_categories():
return mark_safe(result) return mark_safe(result)
@register.filter @register.filter
def small_cat(category, url=None): def small_cat(category, url=None, contrast=True):
class_contrast = " contrast" if contrast else ""
if url is None: if url is None:
return mark_safe('<span class="small-cat" role="button"><span class="cat ' + category.css_class() + '"></span> ' + category.name + "</span>") return mark_safe('<span class="small-cat' + class_contrast +'" role="button"><span class="cat ' + category.css_class() + '"></span> ' + category.name + "</span>")
else: else:
return mark_safe('<a class="small-cat" role="button" href="' + url + '"><span class="cat ' + category.css_class() + '"></span> ' + category.name + "</a>") return mark_safe('<a class="small-cat' + class_contrast +'" role="button" href="' + url + '"><span class="cat ' + category.css_class() + '"></span> ' + category.name + "</a>")