From 2911915bceb9dd040eea347297f6a35bee5af59d Mon Sep 17 00:00:00 2001 From: Tobias dpausp Date: Mon, 26 Dec 2022 15:01:14 +0100 Subject: [PATCH] wip admin dashboad --- .../ekklesia_portal/cell/admin_area.py | 30 +++++++ .../concepts/ekklesia_portal/cell/layout.py | 9 +- .../templates/admin_area.j2.jade | 85 ++++++++++++++++++- .../ekklesia_portal/view/admin_area.py | 2 +- 4 files changed, 123 insertions(+), 3 deletions(-) diff --git a/src/ekklesia_portal/concepts/ekklesia_portal/cell/admin_area.py b/src/ekklesia_portal/concepts/ekklesia_portal/cell/admin_area.py index ddb2da77..fe48989d 100644 --- a/src/ekklesia_portal/concepts/ekklesia_portal/cell/admin_area.py +++ b/src/ekklesia_portal/concepts/ekklesia_portal/cell/admin_area.py @@ -10,3 +10,33 @@ class AdminAreaCell(LayoutCell): def admin_box(self): return AdminBox() + def is_global_admin(self): + return self._request.current_user and self._request.identity.has_global_admin_permissions + + def managed_departments(self): + return self.current_user.managed_departments + + def queued_messages(self): + return [ + dict(author="testuser", subject="Bitte Antrag XY löschen", body="War ne blöde Idee, sorry"), + dict(author="testadmin", subject="Schau dir mal user testuser an", body="Macht komische Dinge"), + dict(author="testuser", subject="Bitte Antrag XY löschen", body="War ne blöde Idee, sorry"), + dict(), + dict(), + dict(), + dict(), + dict(), + ] + + def queued_propositions(self): + return [ + dict(author="testuser", title="Antrag XY", content="Der Vorstand wird verpflichtet..."), + dict(author="testuser", title="Antrag 1", content="..."), + dict(author="testuser", title="Antrag 2", content="..."), + dict(), + dict(), + dict(), + dict(), + dict(), + dict(), + ] diff --git a/src/ekklesia_portal/concepts/ekklesia_portal/cell/layout.py b/src/ekklesia_portal/concepts/ekklesia_portal/cell/layout.py index 6503aa31..ea9416a8 100644 --- a/src/ekklesia_portal/concepts/ekklesia_portal/cell/layout.py +++ b/src/ekklesia_portal/concepts/ekklesia_portal/cell/layout.py @@ -59,7 +59,14 @@ def admin_area_url(self): return self.link(AdminArea()) def show_admin_area(self): - return self.current_user and self._request.identity.has_global_admin_permissions + if self.current_user is None: + return False + + if self._request.identity.has_global_admin_permissions: + return True + + if self.current_user.managed_departments: + return True def show_login_button(self): return self._s.app.login_visible diff --git a/src/ekklesia_portal/concepts/ekklesia_portal/templates/admin_area.j2.jade b/src/ekklesia_portal/concepts/ekklesia_portal/templates/admin_area.j2.jade index 5a9887b3..f06d7ac5 100644 --- a/src/ekklesia_portal/concepts/ekklesia_portal/templates/admin_area.j2.jade +++ b/src/ekklesia_portal/concepts/ekklesia_portal/templates/admin_area.j2.jade @@ -3,12 +3,95 @@ - block content h2 Admin + + if is_global_admin + p + strong Du bist globaler Admin + + .row + .col-sm-6 + .card + .card-body + h2.card-title + a(href="#") Wartende Anträge + |  + span.badge.badge-primary= queued_propositions|length + + .card-text + for proposition in queued_propositions[:3] + .card + .card-body + h5.card-title + p= proposition.title + small Von: + = proposition.author + .card-text + .message_actions + .btn.btn-secondary.btn-sm Veröffentlichen + .btn.btn-danger.btn-sm Löschen + .btn.btn-danger.btn-sm Ignorieren + hr + p= proposition.content + + a(href="#") + small Es werden nur 3 von 9 Anträgen angezeigt, alle anzeigen... + + + .col-sm-6 + .card + .card-body + h2.card-title + a(href="#") Nachrichten + |  + span.badge.badge-primary= queued_messages|length + .card-text + for message in queued_messages[:3] + .card + .card-body + h5.card-title + p= message.subject + small Von: {{ message.author }} + .card-text + .message_actions + .btn.btn-secondary.btn-sm Antworten + .btn.btn-secondary.btn-sm Als Abgeschlossen markieren + .btn.btn-danger.btn-sm Ignorieren + hr + p= message.body + + a(href="#") + small Es werden nur 3 von 8 Nachrichten angezeigt, alle anzeigen... + + hr + .row .col-sm-6 .card .card-body + h2.card-title + a(href="#") Meine Gliederungen + |  + span.badge.badge-primary= managed_departments|length .card-text - = render_cell(admin_box) + for department in managed_departments[:3] + .card + .card-body + h5.card-title= department.name + .card-text + .message_actions + .btn.btn-secondary.btn-sm Neuer Antrag + .btn.btn-secondary.btn-sm Neue Abstimmungsphase + .btn.btn-secondary.btn-sm Alle Anträge + + if is_global_admin + .col-sm-6 + .card + .card-body + h2.card-title Admin-Aktionen + .card-text + = render_cell(admin_box) + + // generated from jade diff --git a/src/ekklesia_portal/concepts/ekklesia_portal/view/admin_area.py b/src/ekklesia_portal/concepts/ekklesia_portal/view/admin_area.py index 0c1c90cd..c6aebdc5 100644 --- a/src/ekklesia_portal/concepts/ekklesia_portal/view/admin_area.py +++ b/src/ekklesia_portal/concepts/ekklesia_portal/view/admin_area.py @@ -5,7 +5,7 @@ @App.permission_rule(model=AdminArea, permission=ViewPermission) def admin_area_view_permission(identity, model, permission): - return identity.has_global_admin_permissions + return identity.has_global_admin_permissions or identity.user.managed_departments @App.path(model=AdminArea, path='/admin')