diff --git a/shiftregister/app/templates/partials/shift_listitem.html b/shiftregister/app/templates/partials/shift_listitem.html index ef64939..0354c20 100644 --- a/shiftregister/app/templates/partials/shift_listitem.html +++ b/shiftregister/app/templates/partials/shift_listitem.html @@ -8,7 +8,8 @@ {% endif %} Ort: {{ shift.room.name }}
Beginn: {{ shift.start_at }}
- Dauer: {{ shift.duration|duration }} + Dauer: {{ shift.duration|duration }}
+ Belegung: {{ shift.reg_count }}/{{ shift.required_helpers|default:shift.room.required_helpers }}
Details diff --git a/shiftregister/app/templates/shift.html b/shiftregister/app/templates/shift.html index 4dffdec..522def9 100644 --- a/shiftregister/app/templates/shift.html +++ b/shiftregister/app/templates/shift.html @@ -20,7 +20,8 @@ Ort: {{ shift.room.name }} 📍
Beginn: {{ shift.start_at }}
Dauer: {{ shift.duration|duration }}
- Treffpunkt: {{ shift.room.meeting_location|linebreaksbr }} + Treffpunkt: {{ shift.room.meeting_location|linebreaksbr }}
+ Belegung: {{ shift.shiftregistration_set.count }}/{{ shift.required_helpers|default:shift.room.required_helpers }}

{% if shift.room.description %}
diff --git a/shiftregister/team/templates/partials/shift_box.html b/shiftregister/team/templates/partials/shift_box.html index 7e10782..6f6c5d0 100644 --- a/shiftregister/team/templates/partials/shift_box.html +++ b/shiftregister/team/templates/partials/shift_box.html @@ -6,7 +6,7 @@ Ort: {{ shift.room.name }}
Beginn: {{ shift.start_at }}
Dauer: {{ shift.duration }}
- Belegung: {{ shift.shiftregistration_set.count }}/{{ shift.required_helpers|default:shift.room.required_helpers }} + Belegung: {{ shift.reg_count}}/{{ shift.required_helpers|default:shift.room.required_helpers }} {% if shift.teambackup_set.all.count %}
Backup-Teammitglied(er): {% for member in shift.teambackup_set.all %}{{ member.name }}{% if not forloop.last %}, {% endif %}{% endfor %} diff --git a/shiftregister/team/views.py b/shiftregister/team/views.py index 0683684..67dabe1 100644 --- a/shiftregister/team/views.py +++ b/shiftregister/team/views.py @@ -23,7 +23,8 @@ def shift_overview(request): context = {} context["running_shifts"] = [ shift - for shift in Shift.objects.annotate( + for shift in Shift.with_reg_count() + .annotate( end_at=ExpressionWrapper( F("start_at") + F("duration"), output_field=DateTimeField(), @@ -37,7 +38,8 @@ def shift_overview(request): context["next_shifts"] = filter( lambda x: x is not None, ( - Shift.objects.filter(room=room, start_at__gt=timezone.now(), deleted=False) + Shift.with_reg_count() + .filter(room=room, start_at__gt=timezone.now(), deleted=False) .order_by("start_at") .first() for room in Room.objects.all().order_by("name") @@ -181,6 +183,9 @@ class ShiftList(LoginRequiredMixin, ListView): model = Shift title = "Alle Schichten" + def get_queryset(self): + return Shift.with_reg_count() + def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context["title"] = self.title