From 6209a2671efe63b03d086e91f37d8c80e6747b6f Mon Sep 17 00:00:00 2001 From: "Andreas (@xAndy) Zimmermann" Date: Fri, 15 Apr 2022 18:26:07 +0200 Subject: [PATCH] add more messages for better helper feedback --- shiftregister/app/views.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/shiftregister/app/views.py b/shiftregister/app/views.py index c2510a9..7247d29 100644 --- a/shiftregister/app/views.py +++ b/shiftregister/app/views.py @@ -58,6 +58,11 @@ def login(request, token): if not tk.helper.number_validated: tk.helper.number_validated = True tk.helper.save() + messages.add_message( + request, + messages.SUCCESS, + "Nummer bestätigt, Du kannst dich jetzt für Schichten anmelden", + ) request.session["token"] = token # if the user was viewing a single shift before registering, they probably want to register for that # shift so we redirect them there. @@ -126,10 +131,27 @@ def shift(request, shiftid): if EmptyForm(request.POST).is_valid(): if not helper: # todo: add flash message that signup is required? + messages.add_message( + request, + messages.WARNING, + "Bitte registriere Dich, bevor du dich zu Schichten anmeldest", + ) return redirect("register") + if not helper.number_validated: + messages.add_message( + request, + messages.WARNING, + "Bitte bestätige zuerst deine Telefonnummer", + ) + return redirect("shift", shiftid=shift.pk) if context["can_register"]: s = ShiftRegistration(helper=helper, shift=shift) s.save() + messages.add_message( + request, + messages.SUCCESS, + "Erfolgreich angemeldet, bitte komme eine halbe Stunde vor deiner Schicht an den Infopoint", + ) # redirect so page can be reloaded without resending post data return redirect("shift", shiftid=shift.pk) return render(request, "shift.html", context) @@ -147,4 +169,15 @@ def cancel(request, shiftid): reg = get_object_or_404(ShiftRegistration, helper=helper, shift=shift) if reg.can_cancel(): reg.delete() + messages.add_message( + request, + messages.SUCCESS, + "Erfolgreich abgemeldet", + ) + else: + messages.add_message( + request, + messages.WARNING, + "Abmeldung nicht (mehr) möglich, bitte wende dich an den Infopoint", + ) return redirect("shift", shiftid=shiftid)