diff --git a/shiftregister/team/templates/partials/shift_box.html b/shiftregister/team/templates/partials/shift_box.html index 7fcb4b3..9256688 100644 --- a/shiftregister/team/templates/partials/shift_box.html +++ b/shiftregister/team/templates/partials/shift_box.html @@ -7,7 +7,11 @@ Ort: {{ shift.room.name }}
Beginn: {{ shift.start_at }}
Dauer: {{ shift.duration }}
+{% if shift.event.calendar.restricted %} + Nur Team: {{ shift.required_helpers|default:shift.room.required_helpers }} +{% else %} Belegung: {{ shift.registration_count }}/{{ shift.required_helpers|default:shift.room.required_helpers }} +{% endif %} {% if shift.checkin_count is not None %}
Checkin-Status: {% if shift.checkin_count >= shift.required_helpers|default:shift.room.required_helpers %}vollständig{% elif shift.checkin_count > 0 %}teilweise{% else %}kein Checkin{% endif %} diff --git a/shiftregister/team/templates/shift_detail.html b/shiftregister/team/templates/shift_detail.html index 71357bb..306dbfc 100644 --- a/shiftregister/team/templates/shift_detail.html +++ b/shiftregister/team/templates/shift_detail.html @@ -6,7 +6,12 @@

{% if shift.deleted %}(gelöscht) {% endif %} {{ shift.room.name }} - {{ shift.start_at }} ({{ shift.registration_count }}/{{ shift.required_helpers|default:shift.room.required_helpers }}) + {{ shift.start_at }} +{% if shift.event.calendar.restricted %} + ({{ shift.required_helpers|default:shift.room.required_helpers }} Teamis) +{% else %} + ({{ shift.registration_count }}/{{ shift.required_helpers|default:shift.room.required_helpers }}) +{% endif %}

{% if shift.room.description %}
@@ -53,10 +58,10 @@ {% endfor %}
{% endif %} -{% if shift.event.fallbackassignment_set.count > 0 %} +{% if shift.fallbackassignment_set.count > 0 %}
Teammitglieder
-{% for fallback in shift.event.fallbackassignment_set.all %} +{% for fallback in shift.fallbackassignment_set.all %}
{% if fallback.traded_to %} @@ -69,6 +74,7 @@ {% endfor %}
{% endif %} +{% if not shift.event.calendar.restricted %}
Helfi eintragen
{% csrf_token %} @@ -97,4 +103,5 @@ {% endfor %}
+{% endif %} {% endblock %} diff --git a/shiftregister/team/views.py b/shiftregister/team/views.py index 21aae57..2b8c959 100644 --- a/shiftregister/team/views.py +++ b/shiftregister/team/views.py @@ -45,17 +45,9 @@ def shift_overview(request): context = {} context["running_shifts"] = ( Shift.all_objects.with_reg_count() - .prefetch_related("event__calendar") + .select_related("event__calendar") .annotate( - checkin_count=Count( - Case( - When( - shiftregistration__state=ShiftRegistration.RegState.CHECKED_IN, - then=1, - ), - output_field=models.IntegerField(), - ) - ), + checkin_count=checkin_count, end_at=ExpressionWrapper( F("start_at") + F("duration"), output_field=DateTimeField() ), @@ -66,7 +58,7 @@ def shift_overview(request): context["next_shifts"] = ( Shift.all_objects.with_reg_count() - .prefetch_related("event__calendar") + .select_related("event__calendar") .annotate(checkin_count=checkin_count) .filter( start_at__gt=timezone.now(), @@ -81,7 +73,7 @@ def shift_overview(request): lambda x: x is not None, ( Shift.all_objects.with_reg_count() - .prefetch_related("event__calendar") + .select_related("event__calendar") .filter(room=room, start_at__gt=timezone.now(), deleted=False) .order_by("start_at") .first() @@ -284,8 +276,7 @@ class CheckinList(LoginRequiredMixin, ListView): def get_queryset(self): return ( - ShiftRegistration.objects.select_related("helper", "shift") - .prefetch_related("shift__event__calendar") + ShiftRegistration.objects.select_related("helper", "shift__event__calendar") .filter(shift__deleted=False, state=ShiftRegistration.RegState.REGISTERED) .order_by("shift__start_at", "shift__room__name") )