2
0
Fork 0

Prevent shift signup when shift was deleted

This commit is contained in:
Luca 2022-04-27 21:35:28 +02:00
parent c6dd5b5eca
commit e0435df07d
3 changed files with 14 additions and 1 deletions

View File

@ -77,7 +77,8 @@ class ShiftRegistration(models.Model):
def can_cancel(self): def can_cancel(self):
return self.shift.start_at > ( 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): def send_reminder(self):

View File

@ -178,6 +178,13 @@ def shift(request, shiftid):
"Bitte bestätige zuerst deine Telefonnummer", "Bitte bestätige zuerst deine Telefonnummer",
) )
return redirect("shift", shiftid=shift.pk) 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"]: if context["can_register"]:
s = ShiftRegistration(helper=helper, shift=shift) s = ShiftRegistration(helper=helper, shift=shift)
s.save() s.save()

View File

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