2
0
Fork 0

implement my_fallback_shifts view

This commit is contained in:
Florian Sorg 2023-05-13 01:59:05 +02:00
parent f5690bc866
commit 332fb0b4cd
5 changed files with 64 additions and 5 deletions

View File

@ -4,14 +4,13 @@ from django.db import migrations
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
('fallback', '0003_fallbackassignment_slot_teammember_fallback_shifts'), ("fallback", "0003_fallbackassignment_slot_teammember_fallback_shifts"),
] ]
operations = [ operations = [
migrations.RemoveField( migrations.RemoveField(
model_name='fallbackassignment', model_name="fallbackassignment",
name='slot', name="slot",
), ),
] ]

View File

@ -0,0 +1,37 @@
{% extends "base.html" %}
{% block head %}
{% endblock %}
{% block body %}
<section class="section">
<div class="container">
<h2 class="title">Fallback-Schichten für {{ team_member.name }}</h2>
<table class="table">
<thead>
<tr>
<th>Wann</th>
<th>Wo</th>
<th>Helfer:innen</th>
<th>Team-Mitglieder</th>
</tr>
</thead>
<tbody>
{% for shift in shifts %}
<tr {% if shift.registration_count == shift.required_helpers|default:shift.room.required_helpers %}style="opacity: 0.2"{% endif %}>
<td>{{ shift.start_at }}</td>
<td>{{ shift.room.name }} </td>
<td>{{ shift.registration_count }}/{{ shift.required_helpers|default:shift.room.required_helpers }}</td>
<td>
{% for assignment in shift.fallbackassignment_set.all %}
{{ assignment.team_member.name }}{% if not forloop.last %}, {% endif %}
{% endfor %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</section>
{% endblock %}

View File

@ -0,0 +1,11 @@
from django.urls import path
from . import views
urlpatterns = [
path(
"fallback_shifts/<int:team_member_id>",
views.my_fallback_shifts,
name="my_fallback_shifts",
),
]

View File

@ -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. # 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)

View File

@ -22,5 +22,6 @@ urlpatterns = [
path("", include("shiftregister.pages.urls")), path("", include("shiftregister.pages.urls")),
path("team/", include("shiftregister.team.urls")), path("team/", include("shiftregister.team.urls")),
path("team/", include("shiftregister.signage.urls")), path("team/", include("shiftregister.signage.urls")),
path("team/", include("shiftregister.fallback.urls")),
path("admin/", admin.site.urls), path("admin/", admin.site.urls),
] ]