From 1dc83050277a8d6fb6565bf1d899f09b3714ca85 Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Tue, 24 Sep 2024 14:27:44 +0200 Subject: [PATCH] chore(index): Move the links outside of the class --- src/dgsi/templates/_index_link.html | 2 +- src/dgsi/views.py | 42 ++++++++++++++--------------- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/src/dgsi/templates/_index_link.html b/src/dgsi/templates/_index_link.html index ae98b12..c89b0cf 100644 --- a/src/dgsi/templates/_index_link.html +++ b/src/dgsi/templates/_index_link.html @@ -1,4 +1,4 @@ - + {% if link.icon %}{% endif %} {{ link.text }} diff --git a/src/dgsi/views.py b/src/dgsi/views.py index 239f30d..0d142fb 100644 --- a/src/dgsi/views.py +++ b/src/dgsi/views.py @@ -24,34 +24,32 @@ class Link(NamedTuple): icon: str | None = None +AUTHENTICATED_LINKS: list[Link] = [ + Link("is-primary", "dgsi:dgn-profile", _("Mon profil"), "user-filled"), + Link("is-primary", "dgsi:dgn-legal_documents", _("Documents Légaux"), "script"), +] + +ADMIN_LINKS: list[Link] = [ + Link( + "is-danger", + "dgsi:dgn-create_user", + _("Créer un nouveau compte Kanidm"), + "user-plus", + ), + Link( + "is-warning", "admin:index", _("Interface d'administration"), "settings-filled" + ), +] + + class IndexView(TemplateView): template_name = "dgsi/index.html" def get_context_data(self, **kwargs: Any) -> dict[str, Any]: return super().get_context_data( links={ - "authenticated": [ - Link( - "is-primary", - "dgsi:dgn-profile", - _("Mon profil"), - "user-filled", - ), - ], - "admin": [ - Link( - "is-danger", - "dgsi:dgn-create_user", - _("Créer un nouveau compte Kanidm"), - "user-plus", - ), - Link( - "is-warning", - "admin:index", - _("Interface d'administration"), - "settings-filled", - ), - ], + "authenticated": AUTHENTICATED_LINKS, + "admin": ADMIN_LINKS, }, **kwargs, )