Prevent shift signup when shift was deleted

pull/1/head
Luca 3 years ago
parent c6dd5b5eca
commit e0435df07d

@ -77,7 +77,8 @@ class ShiftRegistration(models.Model):
def can_cancel(self):
return self.shift.start_at > (
timezone.now() + global_preferences_registry.manager()["helper__min_cancel_time"]
timezone.now()
+ global_preferences_registry.manager()["helper__min_cancel_time"]
)
def send_reminder(self):

@ -178,6 +178,13 @@ def shift(request, shiftid):
"Bitte bestätige zuerst deine Telefonnummer",
)
return redirect("shift", shiftid=shift.pk)
if shift.deleted:
messages.add_message(
request,
messages.ERROR,
"Diese Schicht wurde gelöscht.",
)
return redirect("index")
if context["can_register"]:
s = ShiftRegistration(helper=helper, shift=shift)
s.save()

@ -15,6 +15,7 @@ from os import getenv
import sentry_sdk
from sentry_sdk.integrations.celery import CeleryIntegration
from sentry_sdk.integrations.django import DjangoIntegration
from django.contrib.messages import constants as messages
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
@ -166,3 +167,7 @@ if getenv("SENTRY_DSN"):
)
PHONENUMBER_DEFAULT_REGION = "DE"
MESSAGE_TAGS = {
messages.ERROR: "danger",
}

Loading…
Cancel
Save