From 3caecf63f69ac6e7ee7a8acf6a64318fd9c305cb Mon Sep 17 00:00:00 2001 From: JMARyA Date: Fri, 6 Dec 2024 14:04:17 +0100 Subject: [PATCH] work+roles --- core/azure_auth.py | 12 ++++++++++++ core/styles.py | 2 +- core/templates/component/report.html | 6 +++--- core/templates/index.html | 6 +++--- core/templates/settings.html | 8 ++++++++ core/templates/shell.html | 13 ++++++++++--- core/urls.py | 1 + core/views.py | 11 +++++++++++ 8 files changed, 49 insertions(+), 10 deletions(-) create mode 100644 core/templates/settings.html diff --git a/core/azure_auth.py b/core/azure_auth.py index 64ad1f5..2dee84e 100644 --- a/core/azure_auth.py +++ b/core/azure_auth.py @@ -5,6 +5,13 @@ import base64 from core.models import Berichtsheft from core.reports import DailyReport, WeeklyReport, choose_report_kind import core.util +from enum import Enum + + +class Roles(Enum): + TRAINEE = "trainee" + MANAGER = "manager" + ADMIN = "admin" class AzureUser: @@ -59,3 +66,8 @@ class AzureUser: new_year, new_week = core.util.next_date(new_year, new_week) return count + + @property + def role(self) -> Roles: + # TODO : Implement + return Roles.TRAINEE diff --git a/core/styles.py b/core/styles.py index 1600293..ea7dce0 100644 --- a/core/styles.py +++ b/core/styles.py @@ -2,7 +2,7 @@ STYLE = { "red_btn": "text-white bg-red-700 hover:bg-red-800 focus:outline-none focus:ring-4 focus:ring-red-300 font-medium rounded-full text-sm px-5 py-2.5 text-center me-2 mb-2 dark:bg-red-600 dark:hover:bg-red-700 dark:focus:ring-red-900", - "card": "bg-white drop-shadow-md p-4 mx-auto mt-5 aspect-[2/3] hover:drop-shadow-xl hover:scale-[0.85] scale-[0.8] lg:hover:scale-[0.95] lg:scale-[0.9] transition-all duration-50 transform ease-in-out w-60 sm:w-80", + "card": "bg-white drop-shadow-md p-4 mx-auto mt-5 aspect-[2/3] hover:drop-shadow-xl hover:scale-[0.85] scale-[0.8] lg:hover:scale-[0.95] lg:scale-[0.9] transition-all duration-50 transform ease-in-out w-60 sm:w-80 flex items-center justify-center", "text-input": "w-full p-2 border border-gray-300 rounded-lg focus:ring focus:ring-blue-400 mb-5", } diff --git a/core/templates/component/report.html b/core/templates/component/report.html index 05d8bd4..1bac2d5 100644 --- a/core/templates/component/report.html +++ b/core/templates/component/report.html @@ -1,5 +1,5 @@ - + diff --git a/core/templates/index.html b/core/templates/index.html index ade5705..7655f66 100644 --- a/core/templates/index.html +++ b/core/templates/index.html @@ -24,11 +24,11 @@ {% for report in reports %} {% if forloop.first %} {% if report.week != week_now %} - + {% endif %} {% endif %} {% include 'component/report.html' with report=report %} diff --git a/core/templates/settings.html b/core/templates/settings.html new file mode 100644 index 0000000..9d14eb4 --- /dev/null +++ b/core/templates/settings.html @@ -0,0 +1,8 @@ +{{ title|safe }} + +

+ Benutzer: +

+ +

{{ user.display_name }}

+

{{ user.role.value|capfirst }}

diff --git a/core/templates/shell.html b/core/templates/shell.html index b1a26fb..a4402a5 100644 --- a/core/templates/shell.html +++ b/core/templates/shell.html @@ -8,7 +8,7 @@
- @@ -21,11 +21,18 @@
diff --git a/core/urls.py b/core/urls.py index 6c33d88..dcab3cb 100644 --- a/core/urls.py +++ b/core/urls.py @@ -7,4 +7,5 @@ urlpatterns = [ path("report/", views.report_detail_page, name="report_detail"), path("reports", views.reports_list, name="reports_list"), path("draft", views.report_draft_update, name="report_draft_update"), + path("settings", views.settings_page, name="settings"), ] diff --git a/core/views.py b/core/views.py index 33ac90d..6144704 100644 --- a/core/views.py +++ b/core/views.py @@ -213,3 +213,14 @@ def report_draft_update(request): ) return JsonResponse({"error": "Invalid request method"}, status=400) + + +def settings_page(request): + user = AzureUser(request) + + return htmx_request( + request, + "settings.html", + {"user": user}, + "Einstellungen", + )