diff --git a/shiftregister/app/models.py b/shiftregister/app/models.py index 2dc4def..ea3931c 100644 --- a/shiftregister/app/models.py +++ b/shiftregister/app/models.py @@ -57,12 +57,16 @@ class Shift(models.Model): return (self.start_at <= timezone.now()) and (not self.has_ended()) def registration_count(self): - return self.shiftregistration_set.filter( - state__in=[ - ShiftRegistration.RegState.REGISTERED, - ShiftRegistration.RegState.CHECKED_IN, - ] - ).count() + return ( + self.reg_count + if hasattr(self, "reg_count") + else self.shiftregistration_set.filter( + state__in=[ + ShiftRegistration.RegState.REGISTERED, + ShiftRegistration.RegState.CHECKED_IN, + ] + ).count() + ) class Helper(models.Model): diff --git a/shiftregister/app/templates/partials/shift_listitem.html b/shiftregister/app/templates/partials/shift_listitem.html index 0f495bd..2cc710f 100644 --- a/shiftregister/app/templates/partials/shift_listitem.html +++ b/shiftregister/app/templates/partials/shift_listitem.html @@ -9,7 +9,7 @@ Ort: {{ shift.room.name }}
Beginn: {{ shift.start_at }}
Dauer: {{ shift.duration|duration }}
- Belegung: {{ shift.reg_count }}/{{ shift.required_helpers|default:shift.room.required_helpers }} + Belegung: {{ shift.registration_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 6f687b2..3598c19 100644 --- a/shiftregister/app/templates/shift.html +++ b/shiftregister/app/templates/shift.html @@ -21,7 +21,7 @@ Beginn: {{ shift.start_at }}
Dauer: {{ shift.duration|duration }}
Treffpunkt: {{ shift.room.meeting_location|linebreaksbr }}
- Belegung: {{ shift.reg_count }}/{{ shift.required_helpers|default:shift.room.required_helpers }} + Belegung: {{ shift.registration_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 24d309d..822b034 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.reg_count }}/{{ shift.required_helpers|default:shift.room.required_helpers }} + Belegung: {{ shift.registration_count }}/{{ shift.required_helpers|default:shift.room.required_helpers }}
Details