On affiche une chronologie en pied des événements

This commit is contained in:
Jean-Marie Favreau 2024-12-11 23:27:38 +01:00
parent 504198b14f
commit bc06b6205d
6 changed files with 104 additions and 18 deletions

View File

@ -811,6 +811,29 @@ class Event(models.Model):
models.Index("start_time", "start_day", "end_day", "end_time", Lower("title"), name="datetimes title") models.Index("start_time", "start_day", "end_day", "end_time", Lower("title"), name="datetimes title")
] ]
def chronology(self):
c = []
if self.modified_date:
c.append({ "timestamp": self.modified_date, "data": "modified_date", "user": self.modified_by_user, "is_date": True })
if self.moderated_date:
c.append({ "timestamp": self.moderated_date, "data": "moderated_date", "user" : self.moderated_by_user, "is_date": True})
if self.imported_date:
c.append({ "timestamp": self.imported_date, "data": "imported_date", "user": self.imported_by_user, "is_date": True })
if self.created_date:
c.append({ "timestamp": self.created_date + timedelta(milliseconds=-1), "data": "created_date", "user": self.created_by_user, "is_date": True})
c += [{ "timestamp": m.date, "data": m, "user": m.user, "is_date": False} for m in self.message_set.filter(spam=False)]
if self.other_versions:
for o in self.other_versions.get_duplicated():
if o != self:
c += [{ "timestamp": m.date, "data": m, "user": m.user, "is_date": False} for m in o.message_set.filter(spam=False)]
c.sort(key=lambda x: x["timestamp"])
return c
def sorted_tags(self): def sorted_tags(self):
if self.tags is None: if self.tags is None:
return [] return []

View File

@ -1572,4 +1572,35 @@ label.required::after {
.a-venir .line-now { .a-venir .line-now {
margin-left: -2em; margin-left: -2em;
}
.chronology {
.entree {
display: grid;
grid-template-columns: fit-content(2em) auto;
column-gap: .7em;
.texte {
background: var(--background-color);
padding: 0.1em 0.8em;
border-radius: var(--border-radius);
p {
font-size: 100%;
}
p:last-child {
margin-bottom: 0.1em;
}
}
}
font-size: 85%;
footer {
margin-top: 1.8em;
padding: 0.2em .8em;
}
.ts {
@extend .badge-small;
border-radius: var(--border-radius);
display: inline-block;
width: 14em;
margin-right: 1.2em;
}
} }

View File

@ -1,13 +1,13 @@
{% if user.is_authenticated %} {% if user.is_authenticated %}
<p class="footer">Création&nbsp;: {{ event.created_date }} <p class="footer">Création&nbsp;: {{ event.created_date }}{% if event.created_by_user %} par <em>{{ event.created_by_user.username }}</em>{% endif %}
{% if event.modified %} {% if event.modified %}
— dernière modification&nbsp;: {{ event.modified_date }} — dernière modification&nbsp;: {{ event.modified_date }}{% if event.modified_by_user %} par <em>{{ event.modified_by_user.username }}</em>{% endif %}
{% endif %} {% endif %}
{% if event.imported_date %} {% if event.imported_date %}
— dernière importation&nbsp;: {{ event.imported_date }} — dernière importation&nbsp;: {{ event.imported_date }}{% if event.imported_by_user %} par <em>{{ event.imported_by_user.username }}</em>{% endif %}
{% endif %} {% endif %}
{% if event.moderated_date %} {% if event.moderated_date %}
— dernière modération&nbsp;: {{ event.moderated_date }} — dernière modération&nbsp;: {{ event.moderated_date }}{% if event.moderated_by_user %} par <em>{{ event.moderated_by_user.username }}</em>{% endif %}
{% endif %} {% endif %}
{% if event.pure_import %} {% if event.pure_import %}
<strong>version importée</strong> <strong>version importée</strong>

View File

@ -1,10 +1,12 @@
<footer class="remarque"> <footer class="remarque">
Informations complémentaires non éditables&nbsp;: <strong>Informations complémentaires non éditables</strong>
<ul> <ul>
{% if object.created_date %}<li>Création&nbsp;: {{ object.created_date }}{% if object.created_by_user %} par <em>{{ object.created_by_user.username }}</em>{% endif %}</li>{% endif %} {% if not allbutdates %}
{% if object.modified_date %}<li>Dernière modification&nbsp;: {{ object.modified_date }}{% if object.modified_by_user %} par <em>{{ object.modified_by_user.username }}</em>{% endif %}</li>{% endif %} {% if object.created_date %}<li>Création&nbsp;: {{ object.created_date }}{% if object.created_by_user %} par <em>{{ object.created_by_user.username }}</em>{% endif %}</li>{% endif %}
{% if object.moderated_date %}<li>Dernière modération&nbsp;: {{ object.moderated_date }}{% if object.moderated_by_user %} par <em>{{ object.moderated_by_user.username }}</em>{% endif %}</li>{% endif %} {% if object.modified_date %}<li>Dernière modification&nbsp;: {{ object.modified_date }}{% if object.modified_by_user %} par <em>{{ object.modified_by_user.username }}</em>{% endif %}</li>{% endif %}
{% if object.imported_date %}<li>Dernière importation&nbsp;: {{ object.imported_date }}{% if object.imported_by_user %} par <em>{{ object.imported_by_user.username }}</em>{% endif %}</li>{% endif %} {% if object.moderated_date %}<li>Dernière modération&nbsp;: {{ object.moderated_date }}{% if object.moderated_by_user %} par <em>{{ object.moderated_by_user.username }}</em>{% endif %}</li>{% endif %}
{% if object.imported_date %}<li>Dernière importation&nbsp;: {{ object.imported_date }}{% if object.imported_by_user %} par <em>{{ object.imported_by_user.username }}</em>{% endif %}</li>{% endif %}
{% endif %}
{% if object.uuids %} {% if object.uuids %}
{% if object.uuids|length > 0 %} {% if object.uuids|length > 0 %}
<li>UUIDs (identifiants uniques d'événements dans les sources)&nbsp;: <li>UUIDs (identifiants uniques d'événements dans les sources)&nbsp;:

View File

@ -17,24 +17,54 @@
{% block content %} {% block content %}
{% with cache_timeout=user.is_authenticated|yesno:"30,600" %}
{% cache cache_timeout event user.is_authenticated event %}
<div class="grid two-columns"> <div class="grid two-columns">
<div> <div>
{% with cache_timeout=user.is_authenticated|yesno:"30,600" %}
{% cache cache_timeout event_body user.is_authenticated event %}
{% include "agenda_culturel/single-event/event-single-inc.html" with event=event filter=filter %} {% include "agenda_culturel/single-event/event-single-inc.html" with event=event filter=filter %}
{% endcache %}
{% endwith %}
{% if user.is_authenticated %} {% if user.is_authenticated %}
<article> <article class="chronology">
<header> <header>
<h2>Informations internes</h2> <h2>Chronologie</h2>
</header> </header>
{% include "agenda_culturel/event-info-inc.html" with object=event %} {% for step in event.chronology %}
{% if step.is_date %}
<div class="entree dateline">
<div><span class="ts">{{ step.timestamp }}</span></div>
<div>
{% if step.data == "created_date" %}<em>création</em>{% endif %}
{% if step.data == "modified_date" %}<em>dernière modification</em>{% endif %}
{% if step.data == "moderated_date" %}<em>dernière modération</em>{% endif %}
{% if step.data == "imported_date" %}<em>dernière importation</em>{% endif %}
</div>
</div>
{% else %}
<div class="entree">
<div><span class="ts">{{ step.timestamp }}</span></div>
<div>
<header><strong>Message</strong>{% if step.data.related_event and event != step.data.related_event %} sur <a href="{{ step.data.related_event.get_absolute_url }}">une autre</a> version{% endif %}&nbsp;: <a href="{{ step.data.get_absolute_url }}">{{ step.data.subject|truncatechars:20 }}</a> {% if step.data.user %} par <em>{{ step.data.user }}</em>{% else %} par {{ step.data.name }} (<a href="mailto: {{ step.data.email }}">{{ step.data.email }}</a>){% endif %}</header>
<div class="texte">{{ step.data.message|safe }}</div>
{% if step.data.comments %}
<div><strong>Commentaire&nbsp;:</strong> {{ step.data.comments }}</div>
{% endif %}
</div>
</div>
{% endif %}
{% endfor %}
{% include "agenda_culturel/event-info-inc.html" with allbutdates=1 %}
</article> </article>
{% endif %} {% endif %}
</div> </div>
{% with cache_timeout=user.is_authenticated|yesno:"30,600" %}
{% cache cache_timeout event_aside user.is_authenticated event %}
<aside> <aside>
{% with event.get_concurrent_events as concurrent_events %} {% with event.get_concurrent_events as concurrent_events %}
{% if concurrent_events %} {% if concurrent_events %}
@ -99,10 +129,10 @@
</aside> </aside>
{% endcache %}
{% endwith %}
</div> </div>
{% endcache %}
{% endwith %}
{% endblock %} {% endblock %}

View File

@ -472,7 +472,7 @@ class EventDeleteView(
class EventDetailView(UserPassesTestMixin, DetailView): class EventDetailView(UserPassesTestMixin, DetailView):
model = Event model = Event
template_name = "agenda_culturel/page-event.html" template_name = "agenda_culturel/page-event.html"
queryset = Event.objects.select_related("exact_location").select_related("category").select_related("other_versions").select_related("other_versions__representative") queryset = Event.objects.select_related("exact_location").select_related("category").select_related("other_versions").select_related("other_versions__representative").prefetch_related("message_set")
def test_func(self): def test_func(self):