From 332fb0b4cda84506f425cb6f83cc49490467c617 Mon Sep 17 00:00:00 2001 From: Florian Sorg Date: Sat, 13 May 2023 01:59:05 +0200 Subject: [PATCH] implement my_fallback_shifts view --- .../0004_remove_fallbackassignment_slot.py | 7 ++-- .../templates/my_fallback_shifts.html | 37 +++++++++++++++++++ shiftregister/fallback/urls.py | 11 ++++++ shiftregister/fallback/views.py | 13 ++++++- shiftregister/urls.py | 1 + 5 files changed, 64 insertions(+), 5 deletions(-) create mode 100644 shiftregister/fallback/templates/my_fallback_shifts.html create mode 100644 shiftregister/fallback/urls.py diff --git a/shiftregister/fallback/migrations/0004_remove_fallbackassignment_slot.py b/shiftregister/fallback/migrations/0004_remove_fallbackassignment_slot.py index 50db7a7..8d5eea9 100644 --- a/shiftregister/fallback/migrations/0004_remove_fallbackassignment_slot.py +++ b/shiftregister/fallback/migrations/0004_remove_fallbackassignment_slot.py @@ -4,14 +4,13 @@ from django.db import migrations class Migration(migrations.Migration): - dependencies = [ - ('fallback', '0003_fallbackassignment_slot_teammember_fallback_shifts'), + ("fallback", "0003_fallbackassignment_slot_teammember_fallback_shifts"), ] operations = [ migrations.RemoveField( - model_name='fallbackassignment', - name='slot', + model_name="fallbackassignment", + name="slot", ), ] diff --git a/shiftregister/fallback/templates/my_fallback_shifts.html b/shiftregister/fallback/templates/my_fallback_shifts.html new file mode 100644 index 0000000..07bc986 --- /dev/null +++ b/shiftregister/fallback/templates/my_fallback_shifts.html @@ -0,0 +1,37 @@ +{% extends "base.html" %} + +{% block head %} + +{% endblock %} + +{% block body %} +
+
+

Fallback-Schichten für {{ team_member.name }}

+ + + + + + + + + + + {% for shift in shifts %} + + + + + + + {% endfor %} + +
WannWoHelfer:innenTeam-Mitglieder
{{ shift.start_at }}{{ shift.room.name }} {{ shift.registration_count }}/{{ shift.required_helpers|default:shift.room.required_helpers }} + {% for assignment in shift.fallbackassignment_set.all %} + {{ assignment.team_member.name }}{% if not forloop.last %}, {% endif %} + {% endfor %} +
+
+
+{% endblock %} diff --git a/shiftregister/fallback/urls.py b/shiftregister/fallback/urls.py new file mode 100644 index 0000000..3a43a1c --- /dev/null +++ b/shiftregister/fallback/urls.py @@ -0,0 +1,11 @@ +from django.urls import path + +from . import views + +urlpatterns = [ + path( + "fallback_shifts/", + views.my_fallback_shifts, + name="my_fallback_shifts", + ), +] diff --git a/shiftregister/fallback/views.py b/shiftregister/fallback/views.py index 91ea44a..502c790 100644 --- a/shiftregister/fallback/views.py +++ b/shiftregister/fallback/views.py @@ -1,3 +1,14 @@ -from django.shortcuts import render +from django.shortcuts import render, get_object_or_404 + +from shiftregister.fallback.models import TeamMember # Create your views here. + + +def my_fallback_shifts(request, team_member_id): + team_member = get_object_or_404(TeamMember, pk=team_member_id) + context = {"team_member": team_member, "shifts": team_member.fallback_shifts.all()} + + print(context) + + return render(request, "my_fallback_shifts.html", context) diff --git a/shiftregister/urls.py b/shiftregister/urls.py index 9634741..48ea528 100644 --- a/shiftregister/urls.py +++ b/shiftregister/urls.py @@ -22,5 +22,6 @@ urlpatterns = [ path("", include("shiftregister.pages.urls")), path("team/", include("shiftregister.team.urls")), path("team/", include("shiftregister.signage.urls")), + path("team/", include("shiftregister.fallback.urls")), path("admin/", admin.site.urls), ]