|
|
|
@ -34,8 +34,8 @@ class Shift(models.Model):
|
|
|
|
|
Case(
|
|
|
|
|
When(
|
|
|
|
|
shiftregistration__state__in=[
|
|
|
|
|
ShiftRegistration.REGISTERED,
|
|
|
|
|
ShiftRegistration.CHECKED_IN,
|
|
|
|
|
ShiftRegistration.RegState.REGISTERED,
|
|
|
|
|
ShiftRegistration.RegState.CHECKED_IN,
|
|
|
|
|
],
|
|
|
|
|
then=1,
|
|
|
|
|
),
|
|
|
|
@ -55,7 +55,10 @@ class Shift(models.Model):
|
|
|
|
|
|
|
|
|
|
def registration_count(self):
|
|
|
|
|
return self.shiftregistration_set.filter(
|
|
|
|
|
state__in=[ShiftRegistration.REGISTERED, ShiftRegistration.CHECKED_IN]
|
|
|
|
|
state__in=[
|
|
|
|
|
ShiftRegistration.RegState.REGISTERED,
|
|
|
|
|
ShiftRegistration.RegState.CHECKED_IN,
|
|
|
|
|
]
|
|
|
|
|
).count()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -86,7 +89,10 @@ class Helper(models.Model):
|
|
|
|
|
helper=self,
|
|
|
|
|
shift_end__gte=timezone.now(),
|
|
|
|
|
shift__deleted=False,
|
|
|
|
|
state__in=[ShiftRegistration.REGISTERED, ShiftRegistration.CHECKED_IN],
|
|
|
|
|
state__in=[
|
|
|
|
|
ShiftRegistration.RegState.REGISTERED,
|
|
|
|
|
ShiftRegistration.RegState.CHECKED_IN,
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
.order_by("shift__start_at")
|
|
|
|
|
.first()
|
|
|
|
@ -104,24 +110,19 @@ class ShiftRegistration(models.Model):
|
|
|
|
|
helper = models.ForeignKey(Helper, on_delete=models.CASCADE)
|
|
|
|
|
reminder_sent = models.BooleanField(default=False)
|
|
|
|
|
|
|
|
|
|
# default is registered
|
|
|
|
|
REGISTERED = "REG"
|
|
|
|
|
CHECKED_IN = "CHECK"
|
|
|
|
|
# cancel via infopoint
|
|
|
|
|
CANCELED = "CANCEL"
|
|
|
|
|
# did not attend shift
|
|
|
|
|
FAILED = "FAIL"
|
|
|
|
|
|
|
|
|
|
STATE_CHOICES = [
|
|
|
|
|
(REGISTERED, "registriert"),
|
|
|
|
|
(CHECKED_IN, "checkin"),
|
|
|
|
|
(CANCELED, "abgemeldet"),
|
|
|
|
|
(FAILED, "nicht angetreten"),
|
|
|
|
|
]
|
|
|
|
|
class RegState(models.TextChoices):
|
|
|
|
|
# default is registered
|
|
|
|
|
REGISTERED = "REG", "registriert"
|
|
|
|
|
CHECKED_IN = "CHECK", "checkin"
|
|
|
|
|
# cancel via infopoint
|
|
|
|
|
CANCELED = "CANCEL", "abgemeldet"
|
|
|
|
|
# did not attend shift
|
|
|
|
|
FAILED = "FAIL", "nicht angetreten"
|
|
|
|
|
|
|
|
|
|
state = models.CharField(
|
|
|
|
|
max_length=7,
|
|
|
|
|
choices=STATE_CHOICES,
|
|
|
|
|
default=REGISTERED,
|
|
|
|
|
choices=RegState.choices,
|
|
|
|
|
default=RegState.REGISTERED,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def can_cancel(self):
|
|
|
|
|