From 7c5c1102830fa90d075da1c7dd9c06409b3a0fdc Mon Sep 17 00:00:00 2001 From: Luca Date: Wed, 26 Apr 2023 12:15:50 +0200 Subject: [PATCH] Add setting to disable registration --- shiftregister/app/dynamic_preferences_registry.py | 7 +++++++ shiftregister/app/views.py | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/shiftregister/app/dynamic_preferences_registry.py b/shiftregister/app/dynamic_preferences_registry.py index 597a8e1..59b08f9 100644 --- a/shiftregister/app/dynamic_preferences_registry.py +++ b/shiftregister/app/dynamic_preferences_registry.py @@ -56,3 +56,10 @@ class SMSRate(types.IntegerPreference): name = "sms_rate" default = 2 help_text = "Number of SMS sent per minute" + + +@global_preferences_registry.register +class EnableRegistration(types.BooleanPreference): + section = helper + name = "enable_registration" + default = True diff --git a/shiftregister/app/views.py b/shiftregister/app/views.py index 4790981..200548a 100644 --- a/shiftregister/app/views.py +++ b/shiftregister/app/views.py @@ -119,7 +119,13 @@ def register(request): return redirect("index") context = {} - if request.method == "POST": + if not global_preferences["helper__enable_registration"]: + messages.add_message( + request, + messages.WARNING if request.method == "POST" else messages.INFO, + "Aktuell ist es leider nicht möglich, sich für die Helfer*innen zu registrieren. Bitte komm später wieder.", + ) + elif request.method == "POST": form = RegisterForm(request.POST) if not form.is_valid(): context["form"] = form