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; vertical-align: middle;
margin-bottom: .2em; 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> <h2>Derniers événements soumis</h2>
</header> </header>
{% for e in events %} {% 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 %} {% endfor %}
</article> </article>

View File

@ -2,38 +2,36 @@
{% load utils_extra %} {% load utils_extra %}
{% if event.moderated_date %} {% 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 %} {% 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 %} {% endif %}
{% if event.pure_import %} {% if event.pure_import %}
{% with event.get_local_version as local %} {% with event.get_local_version as local %}
{% if 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 %} {% 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 %} {% endif %}
{% endwith %} {% endwith %}
{% else %} {% 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 %} {% endif %}
{% if event.is_updateable %} {% 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 %} {% 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> <a href="{% url 'change_status_event' event.id 'published' %}" role="button">publier {% picto_from_name "eye" %}</a>
{% endif %} {% endif %}
{% if event.status == "published" %} {% if event.status == "trash" %}
<a href="{% url 'change_status_event' event.id 'draft' %}" role="button">dépublier {% picto_from_name "eye-off" %}</a> {% if details == 1 %}
{% elif event.status == "trash" %} <a href="{% url 'change_status_event' event.id 'draft' %}" role="button">restaurer {% picto_from_name "eye-off" %}</a>
<a href="{% url 'change_status_event' event.id 'draft' %}" role="button">restaurer {% picto_from_name "eye-off" %}</a> {% endif %}
{% endif %} {% else %}
{% if event.status != "trash" %}
<a href="{% url 'change_status_event' event.id 'trash' %}" role="button">supprimer {% picto_from_name "trash-2" %}</a> <a href="{% url 'change_status_event' event.id 'trash' %}" role="button">supprimer {% picto_from_name "trash-2" %}</a>
{% endif %} {% endif %}
@ -41,6 +39,6 @@
<a href="{% url 'delete_event' event.id %}" role="button">supprimer définitivement {% picto_from_name "x-circle" %}</a> <a href="{% url 'delete_event' event.id %}" role="button">supprimer définitivement {% picto_from_name "x-circle" %}</a>
{% endif %} {% endif %}
{% if with_clone %} {% if details == 1 %}
<a href="{% url 'simple_clone_edit' event.id %}" role="button">Dupliquer {% picto_from_name "copy" %}</a> <a href="{% url 'simple_clone_edit' event.id %}" role="button">dupliquer {% picto_from_name "copy" %}</a>
{% endif %} {% endif %}

View File

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

View File

@ -90,7 +90,7 @@
<div class="buttons" style="clear: both"> <div class="buttons" style="clear: both">
{% if perms.agenda_culturel.change_event %} {% 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 %} {% endif %}
</div> </div>
</header> </header>

View File

@ -3,7 +3,8 @@
{% load tag_extra %} {% load tag_extra %}
{% load event_extra %} {% load event_extra %}
<header><h3>{{ event.category | small_cat_recurrent:event.has_recurrences }} <article class="status_{{ event.status }}">
<header><h3>{{ event.category | small_cat_recurrent:event.has_recurrences }}
{{ event|picto_status }} <a href="{{ event.get_absolute_url }}"> {{ event|picto_status }} <a href="{{ event.get_absolute_url }}">
{% if event.title_hl %}{{ event.title_hl | safe }}{% else %}{{ event.title }}{% endif %}</a> {% if event.title_hl %}{{ event.title_hl | safe }}{% else %}{{ event.title }}{% endif %}</a>
{{ event|picto_visibility:user.is_authenticated }} {{ event|picto_visibility:user.is_authenticated }}
@ -67,7 +68,8 @@
<footer> <footer>
<div class="buttons"> <div class="buttons">
{% include "agenda_culturel/event-date-info-inc.html" %} {% include "agenda_culturel/event-date-info-inc.html" %}
{% include "agenda_culturel/edit-buttons-inc.html" with event=event %} {% include "agenda_culturel/edit-buttons-inc.html" with event=event details=0 %}
</div> </div>
</footer> </footer>
{% endif %} {% endif %}
</article>

View File

@ -159,9 +159,9 @@
{% endif %} {% endif %}
{% else %} {% 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 %} {% 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 %}
{% endif %} {% endif %}
</div> </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 "" 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) 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): def form_valid(self, form):
form.instance.set_processing_user(self.request.user) form.instance.set_processing_user(self.request.user)
@ -420,9 +425,12 @@ class EventModerateView(
def get_object(self, queryset=None): def get_object(self, queryset=None):
if self.is_starting_moderation(): if self.is_starting_moderation():
now = datetime.now() now = datetime.now()
return EventModerateView.get_next_event(now.date(), now.time()) event = EventModerateView.get_next_event(now.date(), now.time())
else: 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): def post(self, request, *args, **kwargs):
try: try:
@ -550,7 +558,12 @@ def change_status_event(request, pk, status):
if request.method == "POST": if request.method == "POST":
event.status = Event.STATUS(status) 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) with_msg = event.notify_if_required(request)
if with_msg: 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.")) messages.success(request, _("The status has been successfully modified and a message has been sent to the person who proposed the event."))