diff --git a/shiftregister/app/models.py b/shiftregister/app/models.py index 68435de..2e80da6 100644 --- a/shiftregister/app/models.py +++ b/shiftregister/app/models.py @@ -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): diff --git a/shiftregister/app/views.py b/shiftregister/app/views.py index e2159e2..0a97207 100644 --- a/shiftregister/app/views.py +++ b/shiftregister/app/views.py @@ -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() diff --git a/shiftregister/settings.py b/shiftregister/settings.py index 320ad19..e56c8a1 100644 --- a/shiftregister/settings.py +++ b/shiftregister/settings.py @@ -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", +}