On ajoute une entrée dans le menu pour séparer messages de contact et les autres

This commit is contained in:
Jean-Marie Favreau 2025-01-26 11:49:29 +01:00
parent 31d759e351
commit c020261da3
3 changed files with 16 additions and 5 deletions

View File

@ -440,6 +440,9 @@ class SimpleSearchEventFilter(django_filters.FilterSet):
if not kwargs["request"].user.is_authenticated:
self.form.fields.pop("status")
def is_contact_messages(self):
return "message_type" in self.form.cleaned_data and "contact_form" in self.form.cleaned_data["message_type"]
class SearchEventFilter(django_filters.FilterSet):
tags = django_filters.CharFilter(lookup_expr="icontains")

View File

@ -1,6 +1,6 @@
{% extends "agenda_culturel/page-admin.html" %}
{% block title %}{% block og_title %}Derniers messages de contact reçus{% endblock %}{% endblock %}
{% block title %}{% block og_title %}{% if filter.is_contact_messages %}Derniers messages de contact reçus{% else %}Derniers messages{% endif %}{% endblock %}{% endblock %}
{% load utils_extra %}
{% load cat_extra %}
@ -17,13 +17,16 @@
<div class="grid two-columns">
<article>
<header>
{% if nb_spams > 0 %}
{% if nb_spams > 0 and filter.is_contact_messages %}
<div class="slide-buttons">
<a href="{% url 'delete_cm_spam' %}" role="button" data-tooltip="Supprimer les spams">Supprimer les spams {% picto_from_name "trash-2" %}</a>
</div>
{% endif %}
{% if filter.is_contact_messages %}
<h1>Derniers messages de contact reçus</h1>
{% else %}
<h1>Derniers messages</h1>
{% endif %}
<form method="get" class="form django-form recent messages">
{{ filter.form.as_div }}<br />
<button type="submit">Filtrer</button>
@ -61,7 +64,11 @@
</footer>
</article>
{% if filter.is_contact_messages %}
{% include "agenda_culturel/side-nav.html" with current="messages" %}
{% else %}
{% include "agenda_culturel/side-nav.html" with current="contact_messages" %}
{% endif %}
</div>
{% endblock %}

View File

@ -60,7 +60,8 @@
<h3>Messages</h3>
<nav>
<ul>
<li><a {% if current == "messages" %}class="selected" {% endif %}href="{% url 'messages' %}">Messages de contact</a>{% show_badge_messages "left" %}</li>
<li><a {% if current == "contact_messages" %}class="selected" {% endif %}href="{% url 'messages' %}?message_type=contact_form">Messages de contact</a></li>
<li><a {% if current == "messages" %}class="selected" {% endif %}href="{% url 'messages' %}">Tous les messages</a>{% show_badge_messages "left" %}</li>
</ul>
</nav>
{% endif %}