work+roles
This commit is contained in:
parent
d64efb663a
commit
3caecf63f6
8 changed files with 49 additions and 10 deletions
|
@ -5,6 +5,13 @@ import base64
|
||||||
from core.models import Berichtsheft
|
from core.models import Berichtsheft
|
||||||
from core.reports import DailyReport, WeeklyReport, choose_report_kind
|
from core.reports import DailyReport, WeeklyReport, choose_report_kind
|
||||||
import core.util
|
import core.util
|
||||||
|
from enum import Enum
|
||||||
|
|
||||||
|
|
||||||
|
class Roles(Enum):
|
||||||
|
TRAINEE = "trainee"
|
||||||
|
MANAGER = "manager"
|
||||||
|
ADMIN = "admin"
|
||||||
|
|
||||||
|
|
||||||
class AzureUser:
|
class AzureUser:
|
||||||
|
@ -59,3 +66,8 @@ class AzureUser:
|
||||||
new_year, new_week = core.util.next_date(new_year, new_week)
|
new_year, new_week = core.util.next_date(new_year, new_week)
|
||||||
|
|
||||||
return count
|
return count
|
||||||
|
|
||||||
|
@property
|
||||||
|
def role(self) -> Roles:
|
||||||
|
# TODO : Implement
|
||||||
|
return Roles.TRAINEE
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
STYLE = {
|
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",
|
"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",
|
"text-input": "w-full p-2 border border-gray-300 rounded-lg focus:ring focus:ring-blue-400 mb-5",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<button class="{{ style.card }}"
|
<a class="{{ style.card }}"
|
||||||
|
href="/report/{{ report.id }}"
|
||||||
hx-get="/report/{{ report.id }}" hx-target="#main_content" hx-push-url="true" hx-swap="innerHTML"
|
hx-get="/report/{{ report.id }}" hx-target="#main_content" hx-push-url="true" hx-swap="innerHTML"
|
||||||
>
|
>
|
||||||
{% if report.is_approved %}
|
{% if report.is_approved %}
|
||||||
|
@ -9,4 +9,4 @@ hx-get="/report/{{ report.id }}" hx-target="#main_content" hx-push-url="true" hx
|
||||||
✓
|
✓
|
||||||
</div>
|
</div>
|
||||||
{% endif %} {{ report }}
|
{% endif %} {{ report }}
|
||||||
</button>
|
</a>
|
||||||
|
|
|
@ -24,11 +24,11 @@
|
||||||
{% for report in reports %}
|
{% for report in reports %}
|
||||||
|
|
||||||
{% if forloop.first %} {% if report.week != week_now %}
|
{% if forloop.first %} {% if report.week != week_now %}
|
||||||
<button class="{{ style.card }} flex items-center justify-center" title="Neues Berichtsheft"
|
<a class="{{ style.card }} flex items-center justify-center" title="Neues Berichtsheft"
|
||||||
hx-get="/write" hx-target="#main_content" hx-push-url="true" hx-swap="innerHTML"
|
href="/write" hx-get="/write" hx-target="#main_content" hx-push-url="true" hx-swap="innerHTML"
|
||||||
>
|
>
|
||||||
<span class="text-9xl font-bold"> + </span>
|
<span class="text-9xl font-bold"> + </span>
|
||||||
</button>
|
</a>
|
||||||
{% endif %} {% endif %}
|
{% endif %} {% endif %}
|
||||||
|
|
||||||
{% include 'component/report.html' with report=report %}
|
{% include 'component/report.html' with report=report %}
|
||||||
|
|
8
core/templates/settings.html
Normal file
8
core/templates/settings.html
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{{ title|safe }}
|
||||||
|
|
||||||
|
<p class="text-lg font-bold mx-auto">
|
||||||
|
Benutzer:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p> {{ user.display_name }} </p>
|
||||||
|
<p> {{ user.role.value|capfirst }} </p>
|
|
@ -8,7 +8,7 @@
|
||||||
<!-- Main wrapper that will hold the header, sidebar, and content -->
|
<!-- Main wrapper that will hold the header, sidebar, and content -->
|
||||||
<div class="flex flex-col min-h-screen">
|
<div class="flex flex-col min-h-screen">
|
||||||
<header class="w-full bg-red-600 text-white flex py-4 shadow-md max-h-20 h-full max-h-20">
|
<header class="w-full bg-red-600 text-white flex py-4 shadow-md max-h-20 h-full max-h-20">
|
||||||
<button id="menu-toggle" class="text-2xl focus:outline-none ml-5" onclick="toggleSidepanel()">
|
<button id="menu-toggle" class="text-2xl focus:outline-none ml-5 -mt-1" onclick="toggleSidepanel()">
|
||||||
☰
|
☰
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
@ -21,11 +21,18 @@
|
||||||
<div id="sidepanel" class="w-0 transition-all duration-250 ease-in-out bg-red-600 shadow-md text-white">
|
<div id="sidepanel" class="w-0 transition-all duration-250 ease-in-out bg-red-600 shadow-md text-white">
|
||||||
<ul class="space-y-2 font-medium">
|
<ul class="space-y-2 font-medium">
|
||||||
<li>
|
<li>
|
||||||
<button href="#" onclick="toggleSidepanel()" class="rounded-lg lg:bg-transparent flex w-full items-center p-2 text-gray-900 rounded-lg dark:text-white hover:bg-red-100 dark:hover:bg-red-700 group"
|
<a href="/" onclick="toggleSidepanel()" class="rounded-lg lg:bg-transparent flex w-full items-center p-2 text-gray-900 rounded-lg dark:text-white hover:bg-red-100 dark:hover:bg-red-700 group"
|
||||||
hx-get="/" hx-target="#main_content" hx-push-url="true" hx-swap="innerHTML"
|
hx-get="/" hx-target="#main_content" hx-push-url="true" hx-swap="innerHTML"
|
||||||
>
|
>
|
||||||
<span class="ms-3">Home</span>
|
<span class="ms-3">Home</span>
|
||||||
</button>
|
</a>
|
||||||
|
|
||||||
|
<a href="/settings" onclick="toggleSidepanel()" class="rounded-lg lg:bg-transparent flex w-full items-center p-2 text-gray-900 rounded-lg dark:text-white hover:bg-red-100 dark:hover:bg-red-700 group"
|
||||||
|
hx-get="/settings" hx-target="#main_content" hx-push-url="true" hx-swap="innerHTML"
|
||||||
|
>
|
||||||
|
<span class="ms-3">Settings</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -7,4 +7,5 @@ urlpatterns = [
|
||||||
path("report/<int:report_id>", views.report_detail_page, name="report_detail"),
|
path("report/<int:report_id>", views.report_detail_page, name="report_detail"),
|
||||||
path("reports", views.reports_list, name="reports_list"),
|
path("reports", views.reports_list, name="reports_list"),
|
||||||
path("draft", views.report_draft_update, name="report_draft_update"),
|
path("draft", views.report_draft_update, name="report_draft_update"),
|
||||||
|
path("settings", views.settings_page, name="settings"),
|
||||||
]
|
]
|
||||||
|
|
|
@ -213,3 +213,14 @@ def report_draft_update(request):
|
||||||
)
|
)
|
||||||
|
|
||||||
return JsonResponse({"error": "Invalid request method"}, status=400)
|
return JsonResponse({"error": "Invalid request method"}, status=400)
|
||||||
|
|
||||||
|
|
||||||
|
def settings_page(request):
|
||||||
|
user = AzureUser(request)
|
||||||
|
|
||||||
|
return htmx_request(
|
||||||
|
request,
|
||||||
|
"settings.html",
|
||||||
|
{"user": user},
|
||||||
|
"Einstellungen",
|
||||||
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue