From d3484e626d5d1f42563d4def4ca79ebc73d92742 Mon Sep 17 00:00:00 2001 From: Karl Determe Date: Fri, 14 Aug 2026 20:50:23 +0200 Subject: [PATCH] feat: implement notification inbox and discussion management views with corresponding templates and reminder command --- .../send_unread_notification_reminders.py | 2 +- .../notifications/discussion_detail.html | 2 +- .../templates/notifications/inbox.html | 591 ++++++++++++------ streetup/notifications/tests.py | 56 +- streetup/notifications/views.py | 83 +-- streetup/templates/base.html | 150 +---- 6 files changed, 513 insertions(+), 371 deletions(-) diff --git a/streetup/notifications/management/commands/send_unread_notification_reminders.py b/streetup/notifications/management/commands/send_unread_notification_reminders.py index 951bb2c..05f3d6a 100644 --- a/streetup/notifications/management/commands/send_unread_notification_reminders.py +++ b/streetup/notifications/management/commands/send_unread_notification_reminders.py @@ -102,7 +102,7 @@ class Command(BaseCommand): html_items = [] for r in valid_recipients: n = r.notification - created_str = n.created_at.strftime('%d/%m/%Y à %H:%i') + created_str = n.created_at.strftime('%d/%m/%Y à %H:%M') sender_str = n.sender.get_full_name() if n.sender else _("Système") link = f"{domain}{n.action_url}" if n.action_url else f"{domain}/notifications/" diff --git a/streetup/notifications/templates/notifications/discussion_detail.html b/streetup/notifications/templates/notifications/discussion_detail.html index 209541f..30117fe 100644 --- a/streetup/notifications/templates/notifications/discussion_detail.html +++ b/streetup/notifications/templates/notifications/discussion_detail.html @@ -82,7 +82,7 @@
- +
diff --git a/streetup/notifications/templates/notifications/inbox.html b/streetup/notifications/templates/notifications/inbox.html index 2e4e4ac..9bbc415 100644 --- a/streetup/notifications/templates/notifications/inbox.html +++ b/streetup/notifications/templates/notifications/inbox.html @@ -20,221 +20,446 @@ font-size: 0.7rem; padding: 2px 6px; } + .discussion-item { + transition: background 0.15s; + border-left: 4px solid transparent; + } + .discussion-item.has-unread { + background-color: #f0f4ff; + border-left-color: var(--brand-color, #2f3e8b); + } + .discussion-item:hover { + background-color: #e8edf8; + text-decoration: none; + } + .avatar-sm { + width: 38px; + height: 38px; + font-size: 0.9rem; + border-radius: 50%; + display: flex; + align-items: center; + justify-content: center; + flex-shrink: 0; + } + .inbox-nav-tabs .nav-link { + font-size: 1.05rem; + padding: 0.6rem 1.25rem; + border: none; + border-bottom: 3px solid transparent; + color: #6c757d; + font-weight: 500; + background: transparent; + } + .inbox-nav-tabs .nav-link:hover { + color: var(--brand-color, #2f3e8b); + border-bottom-color: #dee2e6; + } + .inbox-nav-tabs .nav-link.active { + color: var(--brand-color, #2f3e8b); + font-weight: 700; + border-bottom-color: var(--brand-color, #2f3e8b); + background: transparent; + } {% endblock %} {% block content %}
- -
-

- {% translate "Notifications" %} - {% if unread_count > 0 %} - - {{ unread_count }} - - {% endif %} -

-
- {% if unread_count > 0 %} -
- {% csrf_token %} - -
- {% endif %} - {% if user.config|has_any_role:"admin" %} - - {% translate "Nouvelle notification" %} - - {% endif %} - - {% translate "Discussions" %} - - + + + + + +
- -
-
-
-
- -
-
-
- - -
-
- {% if filter_type or show_archived %} - - {% endif %} -
-
-
+ +
- - {% if notifications %} -
-
- {% for item in notifications %} - {% with notif=item.notification %} -
-
+ +
- -
- - - -
- - -
-
-
- - {{ notif.title }} - - {% if not item.is_read and not item.is_archived %} - {% translate "Nouveau" %} - {% endif %} -
-
- - {% if not item.is_read %} -
- - -
- {% endif %} - - {% if item.recipient_type == 'personal' and not item.is_archived %} - - {% endif %} + +
+
+
+ +
+ +
+
+
+ +
- - {% if notif.content %} -

{{ notif.content|linebreaksbr }}

- {% endif %} - -
- - - {{ notif.get_notification_type_display }} - - {% if item.team_name %} - - {{ item.team_name }} - - {% endif %} - {% if notif.source_app %} - {{ notif.source_app }} - {% endif %} - - {{ notif.created_at|date:"d/m/Y H:i" }} - - {% if notif.sender %} - - {{ notif.sender.get_full_name|default:notif.sender.username }} - - {% endif %} - {% if notif.expires_at %} - - {% translate "Expire le" %} {{ notif.expires_at|date:"d/m/Y H:i" }} - - {% endif %} - {% if notif.action_url and notif.action_url != request.path and notif.action_url != '/notifications/' and notif.action_url != '/notifications' %} - - {{ notif.action_label|default:notif.action_url }} - + {% if filter_type or show_archived %} + - - - {% with attachments=notif.attachments.all %} - {% if attachments %} -
- {% for att in attachments %} - {% if att.is_image %} - - {{ att.name }} - - {% else %} - - {{ att.name }} - - {% endif %} - {% endfor %}
{% endif %} - {% endwith %} -
+
+
+
+ + + {% if notifications %} +
+
+ {% for item in notifications %} + {% with notif=item.notification %} +
+
+ + +
+ + + +
+ + +
+
+
+ + {{ notif.title }} + + {% if not item.is_read and not item.is_archived %} + {% translate "Nouveau" %} + {% endif %} +
+
+ + {% if not item.is_read %} +
+ + +
+ {% endif %} + + {% if item.recipient_type == 'personal' and not item.is_archived %} + + {% endif %} +
+
+ + {% if notif.content %} +

{{ notif.content|linebreaksbr }}

+ {% endif %} + +
+ + + {{ notif.get_notification_type_display }} + + {% if item.team_name %} + + {{ item.team_name }} + + {% endif %} + {% if notif.source_app %} + {{ notif.source_app }} + {% endif %} + + {{ notif.created_at|date:"d/m/Y H:i" }} + + {% if notif.sender %} + + {{ notif.sender.get_full_name|default:notif.sender.username }} + + {% endif %} + {% if notif.expires_at %} + + {% translate "Expire le" %} {{ notif.expires_at|date:"d/m/Y H:i" }} + + {% endif %} + {% if notif.action_url and notif.action_url != request.path and notif.action_url != '/notifications/' and notif.action_url != '/notifications' %} + + {{ notif.action_label|default:notif.action_url }} + + + {% endif %} +
+ + + {% with attachments=notif.attachments.all %} + {% if attachments %} +
+ {% for att in attachments %} + {% if att.is_image %} + + {{ att.name }} + + {% else %} + + {{ att.name }} + + {% endif %} + {% endfor %} +
+ {% endif %} + {% endwith %} +
+
+
+ {% endwith %} + {% endfor %}
- {% endwith %} - {% endfor %} -
-
- {% else %} -
- -

- {% if show_archived %} - {% translate "Aucune notification archivée." %} {% else %} - {% translate "Vous n'avez aucune notification." %} +

+ +

+ {% if show_archived %} + {% translate "Aucune notification archivée." %} + {% else %} + {% translate "Vous n'avez aucune notification." %} + {% endif %} +

+
{% endif %} -

+
+ + + +
- {% endif %}
+ +{% include "notifications/_new_discussion_modal.html" %} {% endblock content %} {% block script %}