From 9f189ce29f702a08ad65697b9cfa87f45ae317d3 Mon Sep 17 00:00:00 2001 From: Jaroslav Beran Date: Fri, 8 Mar 2024 20:18:34 +0100 Subject: [PATCH] Waiting messages --- svjis/articles/templates/admin_messages.html | 29 ++++++++++++++++++++ svjis/articles/urls.py | 1 + svjis/articles/views_admin.py | 15 ++++++++++ 3 files changed, 45 insertions(+) create mode 100644 svjis/articles/templates/admin_messages.html diff --git a/svjis/articles/templates/admin_messages.html b/svjis/articles/templates/admin_messages.html new file mode 100644 index 0000000..41f597f --- /dev/null +++ b/svjis/articles/templates/admin_messages.html @@ -0,0 +1,29 @@ +{% extends "base-with-aside-menu-content.html" %} + +{% load i18n %} + +{% block content %} + +

{% trans 'Waiting messages' %}

+ + + + + + + + + + {% if object_list %} + {% for obj in object_list %} + + + + + + + {% endfor %} + {% endif %} +
 {% trans 'Recipient' %}{% trans 'Subject' %}{% trans 'Creation time' %}
{{ forloop.counter }}{{ obj.email }}{{ obj.subject }}{{ obj.creation_time | date:"d.m.Y H:i" }}
+ +{% endblock %} diff --git a/svjis/articles/urls.py b/svjis/articles/urls.py index 26e3a76..9631ad8 100644 --- a/svjis/articles/urls.py +++ b/svjis/articles/urls.py @@ -36,6 +36,7 @@ path('admin_group_edit//', views_admin.admin_group_edit_view, name='admin_group_edit'), path('admin_group_save/', views_admin.admin_group_save_view, name='admin_group_save'), path('admin_group_delete//', views_admin.admin_group_delete_view, name='admin_group_delete'), + path('admin_messages/', views_admin.admin_messages_view, name='admin_messages'), ] if settings.DEBUG: diff --git a/svjis/articles/views_admin.py b/svjis/articles/views_admin.py index b53e9db..6e05932 100644 --- a/svjis/articles/views_admin.py +++ b/svjis/articles/views_admin.py @@ -14,6 +14,8 @@ def get_side_menu(active_item, user): result.append({'description': _("Users"), 'link': reverse(admin_user_view), 'active': True if active_item == 'users' else False}) if user.has_perm('articles.svjis_edit_admin_groups'): result.append({'description': _("Groups"), 'link': reverse(admin_group_view), 'active': True if active_item == 'groups' else False}) + if user.has_perm('articles.svjis_edit_admin_groups'): + result.append({'description': _("Waiting messages"), 'link': reverse(admin_messages_view), 'active': True if active_item == 'messages' else False}) return result @@ -176,3 +178,16 @@ def admin_group_delete_view(request, pk): obj = get_object_or_404(Group, pk=pk) obj.delete() return redirect(admin_group_view) + + +# Administration - Waiting messages +@permission_required("articles.svjis_edit_admin_groups") +def admin_messages_view(request): + message_list = models.MessageQueue.objects.filter(status=0) + ctx = { + 'aside_menu_name': _("Administration"), + } + ctx['aside_menu_items'] = get_side_menu('messages', request.user) + ctx['tray_menu_items'] = utils.get_tray_menu('admin', request.user) + ctx['object_list'] = message_list + return render(request, "admin_messages.html", ctx)