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 events %}
{% load cat_extra %}
<h1>{{ object.title }}</h1>
<p>Date&nbsp;: {{ object.start_day }}</p>
{% block content %}
<article>
<header>
<h1>{{ object.title }}</h1>
<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 %}

View File

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

View File

@ -11,6 +11,15 @@
{% css_categories %}
{% endblock %}
{% block title %}
{% if category %}
{{ category.alt_name | capfirst }}
{{ selected_mode }}
{% else %}
{{ selected_mode | capfirst }}
{% endif %}
{% endblock %}
{% block content %}
<details role="list">
<summary aria-haspopup="listbox" role="button">
@ -72,17 +81,26 @@
<h2>{{ date |date:"l j F"| capfirst }}</h2>
{% for event in events_date %}
<article>
<h3><a href="{{ event.get_absolute_url }}">{{ event.title }}</a></h3>
{{ event.description }}
<h3>
{% 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>
{% if category %}
<p>{% if category %}
{{ event.category | small_cat }}
{% else %}
{% url 'view_mode_cat' selected_mode.name event.category.pk as url_cat %}
{{ event.category | small_cat:url_cat }}
{% endif %}
</article>
</footer>
{% endif %} </p>
<p>
{% for tag in event.tags %}
<a href="" role="button" class="small-cat">{{ tag }}</a>
{% endfor %}
</p>
</footer>
</article>
{% endfor %}
{% endif %}
{% endwith %}

View File

@ -84,8 +84,10 @@ def css_categories():
return mark_safe(result)
@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:
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:
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>")