|
|
@ -58,6 +58,11 @@ def login(request, token):
|
|
|
|
if not tk.helper.number_validated:
|
|
|
|
if not tk.helper.number_validated:
|
|
|
|
tk.helper.number_validated = True
|
|
|
|
tk.helper.number_validated = True
|
|
|
|
tk.helper.save()
|
|
|
|
tk.helper.save()
|
|
|
|
|
|
|
|
messages.add_message(
|
|
|
|
|
|
|
|
request,
|
|
|
|
|
|
|
|
messages.SUCCESS,
|
|
|
|
|
|
|
|
"Nummer bestätigt, Du kannst dich jetzt für Schichten anmelden",
|
|
|
|
|
|
|
|
)
|
|
|
|
request.session["token"] = token
|
|
|
|
request.session["token"] = token
|
|
|
|
# if the user was viewing a single shift before registering, they probably want to register for that
|
|
|
|
# if the user was viewing a single shift before registering, they probably want to register for that
|
|
|
|
# shift so we redirect them there.
|
|
|
|
# shift so we redirect them there.
|
|
|
@ -126,10 +131,27 @@ def shift(request, shiftid):
|
|
|
|
if EmptyForm(request.POST).is_valid():
|
|
|
|
if EmptyForm(request.POST).is_valid():
|
|
|
|
if not helper:
|
|
|
|
if not helper:
|
|
|
|
# todo: add flash message that signup is required?
|
|
|
|
# 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")
|
|
|
|
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"]:
|
|
|
|
if context["can_register"]:
|
|
|
|
s = ShiftRegistration(helper=helper, shift=shift)
|
|
|
|
s = ShiftRegistration(helper=helper, shift=shift)
|
|
|
|
s.save()
|
|
|
|
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
|
|
|
|
# redirect so page can be reloaded without resending post data
|
|
|
|
return redirect("shift", shiftid=shift.pk)
|
|
|
|
return redirect("shift", shiftid=shift.pk)
|
|
|
|
return render(request, "shift.html", context)
|
|
|
|
return render(request, "shift.html", context)
|
|
|
@ -147,4 +169,15 @@ def cancel(request, shiftid):
|
|
|
|
reg = get_object_or_404(ShiftRegistration, helper=helper, shift=shift)
|
|
|
|
reg = get_object_or_404(ShiftRegistration, helper=helper, shift=shift)
|
|
|
|
if reg.can_cancel():
|
|
|
|
if reg.can_cancel():
|
|
|
|
reg.delete()
|
|
|
|
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)
|
|
|
|
return redirect("shift", shiftid=shiftid)
|
|
|
|