Modification des interactions de modération

Fix #287
This commit is contained in:
Jean-Marie Favreau 2025-01-24 17:08:49 +01:00
parent 3df89e6a52
commit defe0b1792
9 changed files with 116 additions and 93 deletions

View File

@ -1821,3 +1821,15 @@ dialog {
vertical-align: middle;
margin-bottom: .2em;
}
.status_trash header, .status_trash footer,
.status_draft header, .status_draft footer {
background: repeating-linear-gradient(
45deg,
rgba(80, 80, 80, 0.1),
rgba(80, 80, 80, 0.1) 10px,
rgba(80, 80, 80, 0.25) 10px,
rgba(80, 80, 80, 0.25) 20px
),
}

View File

@ -86,7 +86,7 @@
<h2>Derniers événements soumis</h2>
</header>
{% for e in events %}
<article>{% include "agenda_culturel/single-event/event-in-flat-list-inc.html" with event=e %}</article>
{% include "agenda_culturel/single-event/event-in-flat-list-inc.html" with event=e %}
{% endfor %}
</article>

View File

@ -2,38 +2,36 @@
{% load utils_extra %}
{% if event.moderated_date %}
<a href="{% url 'moderate_event' event.id %}" role="button">Modérer de nouveau {% picto_from_name "check-square" %}</a>
<a href="{% url 'moderate_event' event.id %}" role="button">modérer de nouveau {% picto_from_name "check-square" %}</a>
{% else %}
<a href="{% url 'moderate_event' event.id %}" role="button">Modérer {% picto_from_name "check-square" %}</a>
<a href="{% url 'moderate_event' event.id %}" role="button">modérer {% picto_from_name "check-square" %}</a>
{% endif %}
{% if event.pure_import %}
{% with event.get_local_version as local %}
{% if local %}
<a href="{{ local.get_absolute_url }}" role="button">voir la version locale {% picto_from_name "eye" %}</a>
<a href="{{ local.get_absolute_url }}" role="button">Voir la version locale {% picto_from_name "eye" %}</a>
{% else %}
<a href="{% url 'clone_edit' event.id %}" role="button">modifier {% picto_from_name "edit-3" %}</a>
<a href="{% url 'clone_edit' event.id %}" role="button">modifier & modérer {% picto_from_name "edit-3" %}</a>
{% endif %}
{% endwith %}
{% else %}
<a href="{% url 'edit_event' event.id %}" role="button">modifier {% picto_from_name "edit-3" %}</a>
<a href="{% url 'edit_event' event.id %}" role="button">modifier & modérer {% picto_from_name "edit-3" %}</a>
{% endif %}
{% if event.is_updateable %}
<a href="{% url 'update_from_source' event.id %}" role="button">Réimporter {% picto_from_name "download-cloud" %}</a>
<a href="{% url 'update_from_source' event.id %}" role="button">réimporter {% picto_from_name "download-cloud" %}</a>
{% endif %}
{% if event.status != "published" %}
{% if event.status == "draft" and details == 1 %}
<a href="{% url 'change_status_event' event.id 'published' %}" role="button">publier {% picto_from_name "eye" %}</a>
{% endif %}
{% if event.status == "published" %}
<a href="{% url 'change_status_event' event.id 'draft' %}" role="button">dépublier {% picto_from_name "eye-off" %}</a>
{% elif event.status == "trash" %}
<a href="{% url 'change_status_event' event.id 'draft' %}" role="button">restaurer {% picto_from_name "eye-off" %}</a>
{% endif %}
{% if event.status != "trash" %}
{% if event.status == "trash" %}
{% if details == 1 %}
<a href="{% url 'change_status_event' event.id 'draft' %}" role="button">restaurer {% picto_from_name "eye-off" %}</a>
{% endif %}
{% else %}
<a href="{% url 'change_status_event' event.id 'trash' %}" role="button">supprimer {% picto_from_name "trash-2" %}</a>
{% endif %}
@ -41,6 +39,6 @@
<a href="{% url 'delete_event' event.id %}" role="button">supprimer définitivement {% picto_from_name "x-circle" %}</a>
{% endif %}
{% if with_clone %}
<a href="{% url 'simple_clone_edit' event.id %}" role="button">Dupliquer {% picto_from_name "copy" %}</a>
{% if details == 1 %}
<a href="{% url 'simple_clone_edit' event.id %}" role="button">dupliquer {% picto_from_name "copy" %}</a>
{% endif %}

View File

@ -40,7 +40,7 @@
<div>
{% for obj in paginator_filter %}
<article>{% include "agenda_culturel/single-event/event-in-flat-list-inc.html" with event=obj %}</article>
{% include "agenda_culturel/single-event/event-in-flat-list-inc.html" with event=obj %}
{% endfor %}
</div>
<footer>

View File

@ -103,9 +103,7 @@
<p>{{ paginator_filter.paginator.count }} événement{{paginator_filter.object_list.count | pluralize }} correspond{{paginator_filter.object_list.count | pluralize:"ent" }} à la recherche.</p>
<div>
{% for obj in paginator_filter %}
<article>
{% include "agenda_culturel/single-event/event-in-flat-list-inc.html" with event=obj %}
</article>
{% endfor %}
</div>
<footer>

View File

@ -90,7 +90,7 @@
<div class="buttons" style="clear: both">
{% if perms.agenda_culturel.change_event %}
{% include "agenda_culturel/edit-buttons-inc.html" with event=event %}
{% include "agenda_culturel/edit-buttons-inc.html" with event=event details=0 %}
{% endif %}
</div>
</header>

View File

@ -3,71 +3,73 @@
{% load tag_extra %}
{% load event_extra %}
<header><h3>{{ event.category | small_cat_recurrent:event.has_recurrences }}
{{ event|picto_status }} <a href="{{ event.get_absolute_url }}">
{% if event.title_hl %}{{ event.title_hl | safe }}{% else %}{{ event.title }}{% endif %}</a>
{{ event|picto_visibility:user.is_authenticated }}
</h3>
<p class="subentry-search">{% picto_from_name "calendar" %}
{% if event.end_day and event.end_day != event.start_day %}du{% else %}le{% endif %}
{{ event.start_day|date|frdate }}
{% if event.start_time %} {% if not event.end_day or event.end_day == event.start_day %}{% if event.end_time %}de{% else %}à{% endif %}{% endif %}
{{ event.start_time }}
{% endif %}
{% if event.end_day and event.end_day != event.start_day %}
au {% if event.end_day and event.end_day != event.start_day %}{{ event.end_day|date|frdate }}{% endif %}
{% endif %}
{% if event.end_time %} {% if not event.end_day|date|frdate or event.end_day == event.start_day %}jusqu'à{% endif %} {{ event.end_time }}{% endif %}
<p class="subentry-search">
{% if not no_location %}
{% if event.location or event.exact_location %}
{% picto_from_name "map-pin" %}
{% if event.exact_location %}
<a href="{{ event.exact_location.get_absolute_url }}">{{ event.exact_location.name }}, {{ event.exact_location.city }}</a>
{% else %}
{% if perms.agenda_culturel.change_event and perms.agenda_culturel.change_place %}
<a href="{% url 'add_place_to_event' event.pk %}" class="missing-data">{{ event.location }}</a>
{% else %}
{{ event.location }}
{% endif %}
{% endif %}
<article class="status_{{ event.status }}">
<header><h3>{{ event.category | small_cat_recurrent:event.has_recurrences }}
{{ event|picto_status }} <a href="{{ event.get_absolute_url }}">
{% if event.title_hl %}{{ event.title_hl | safe }}{% else %}{{ event.title }}{% endif %}</a>
{{ event|picto_visibility:user.is_authenticated }}
</h3>
<p class="subentry-search">{% picto_from_name "calendar" %}
{% if event.end_day and event.end_day != event.start_day %}du{% else %}le{% endif %}
{{ event.start_day|date|frdate }}
{% if event.start_time %} {% if not event.end_day or event.end_day == event.start_day %}{% if event.end_time %}de{% else %}à{% endif %}{% endif %}
{{ event.start_time }}
{% endif %}
{% endif %}
</p>
</header>
{% if event.has_recurrences %}
{% if event.end_day and event.end_day != event.start_day %}
au {% if event.end_day and event.end_day != event.start_day %}{{ event.end_day|date|frdate }}{% endif %}
{% endif %}
{% if event.end_time %} {% if not event.end_day|date|frdate or event.end_day == event.start_day %}jusqu'à{% endif %} {{ event.end_time }}{% endif %}
<p class="subentry-search">
{% picto_from_name "repeat" %}
<!-- TODO: see https://forge.chapril.org/jmtrivial/agenda_culturel/issues/65 -->
{% for r in event.recurrences.rrules %}
{{ r.to_text }}{% if not forloop.first %}, {% endif %}{% endfor %}, depuis le
{% if event.recurrences.dtstart.date %}
{{ event.recurrences.dtstart.date }}
{% else %}
{{ event.start_day }}
{% endif %}
</p>
{% endif %}
{% if event.tags %}
<p class="subentry-search">
{% picto_from_name "tag" %}
{% for tag in event.sorted_tags %}
<a href="{% url 'view_tag' tag|prepare_tag %}">{{ tag|tw_highlight }}</a>
{% if not forloop.last %}, {% endif %}
{% endfor %}
</p>
{% endif %}
<div class="description">
{% if event.description_hl %}{{ event.description_hl | safe }} [...]{% else %}{% if event.description %}{{ event.description |truncatewords:60 }}{% else %}<em>pas de description</em>{% endif %}{% endif %}
{% if not no_location %}
{% if event.location or event.exact_location %}
{% picto_from_name "map-pin" %}
</div>
{% if perms.agenda_culturel.change_event %}
<footer>
<div class="buttons">
{% include "agenda_culturel/event-date-info-inc.html" %}
{% include "agenda_culturel/edit-buttons-inc.html" with event=event %}
</div>
</footer>
{% endif %}
{% if event.exact_location %}
<a href="{{ event.exact_location.get_absolute_url }}">{{ event.exact_location.name }}, {{ event.exact_location.city }}</a>
{% else %}
{% if perms.agenda_culturel.change_event and perms.agenda_culturel.change_place %}
<a href="{% url 'add_place_to_event' event.pk %}" class="missing-data">{{ event.location }}</a>
{% else %}
{{ event.location }}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
</p>
</header>
{% if event.has_recurrences %}
<p class="subentry-search">
{% picto_from_name "repeat" %}
<!-- TODO: see https://forge.chapril.org/jmtrivial/agenda_culturel/issues/65 -->
{% for r in event.recurrences.rrules %}
{{ r.to_text }}{% if not forloop.first %}, {% endif %}{% endfor %}, depuis le
{% if event.recurrences.dtstart.date %}
{{ event.recurrences.dtstart.date }}
{% else %}
{{ event.start_day }}
{% endif %}
</p>
{% endif %}
{% if event.tags %}
<p class="subentry-search">
{% picto_from_name "tag" %}
{% for tag in event.sorted_tags %}
<a href="{% url 'view_tag' tag|prepare_tag %}">{{ tag|tw_highlight }}</a>
{% if not forloop.last %}, {% endif %}
{% endfor %}
</p>
{% endif %}
<div class="description">
{% if event.description_hl %}{{ event.description_hl | safe }} [...]{% else %}{% if event.description %}{{ event.description |truncatewords:60 }}{% else %}<em>pas de description</em>{% endif %}{% endif %}
</div>
{% if perms.agenda_culturel.change_event %}
<footer>
<div class="buttons">
{% include "agenda_culturel/event-date-info-inc.html" %}
{% include "agenda_culturel/edit-buttons-inc.html" with event=event details=0 %}
</div>
</footer>
{% endif %}
</article>

View File

@ -159,9 +159,9 @@
{% endif %}
{% else %}
<a href="{% url 'export_event_ical' event.start_day.year event.start_day.month event.start_day.day event.id %}" role="button">Exporter ical {% picto_from_name "calendar" %}</a>
<a href="{% url 'export_event_ical' event.start_day.year event.start_day.month event.start_day.day event.id %}" role="button">exporter ical {% picto_from_name "calendar" %}</a>
{% if perms.agenda_culturel.change_event and not noedit %}
{% include "agenda_culturel/edit-buttons-inc.html" with event=event with_clone=1 %}
{% include "agenda_culturel/edit-buttons-inc.html" with event=event details=1 %}
{% endif %}
{% endif %}
</div>

View File

@ -327,6 +327,11 @@ class EventUpdateView(
txt = _(" A message has been sent to the person who proposed the event.") if hasattr(self, "with_msg") and self.with_msg else ""
return mark_safe(_('The event has been successfully modified.') + txt)
def get_object(self, queryset=None):
event = super().get_object(queryset)
if event.status == Event.STATUS.DRAFT:
event.status = Event.STATUS.PUBLISHED
return event
def form_valid(self, form):
form.instance.set_processing_user(self.request.user)
@ -420,9 +425,12 @@ class EventModerateView(
def get_object(self, queryset=None):
if self.is_starting_moderation():
now = datetime.now()
return EventModerateView.get_next_event(now.date(), now.time())
event = EventModerateView.get_next_event(now.date(), now.time())
else:
return super().get_object(queryset)
event = super().get_object(queryset)
if event.status == Event.STATUS.DRAFT:
event.status = Event.STATUS.PUBLISHED
return event
def post(self, request, *args, **kwargs):
try:
@ -550,7 +558,12 @@ def change_status_event(request, pk, status):
if request.method == "POST":
event.status = Event.STATUS(status)
event.save(update_fields=["status"])
fields = ["status"]
if event.status == Event.STATUS.PUBLISHED:
event.set_in_moderation_process()
event.update_modification_dates()
fields += ["moderated_date", "moderated_by_user"]
event.save(update_fields=fields)
with_msg = event.notify_if_required(request)
if with_msg:
messages.success(request, _("The status has been successfully modified and a message has been sent to the person who proposed the event."))