Use a standard login handler

Is there any reason to not use the standard login decorator?
This commit is contained in:
Sachi King 2017-05-07 19:19:53 +10:00
parent 8cb7bcc021
commit 4a5e4dc6ea

View file

@ -71,29 +71,26 @@ def speaker_create_staff(request, pk):
})
@login_required
def speaker_create_token(request, token):
speaker = get_object_or_404(Speaker, invite_token=token)
request.session["pending-token"] = token
if request.user.is_authenticated():
# check for speaker profile
try:
existing_speaker = request.user.speaker_profile
except ObjectDoesNotExist:
pass
else:
del request.session["pending-token"]
additional_speakers = ProposalBase.additional_speakers.through
additional_speakers._default_manager.filter(
speaker=speaker
).update(
speaker=existing_speaker
)
messages.info(request, _("You have been associated with all pending "
"talk proposals"))
return redirect("dashboard")
# check for speaker profile
try:
existing_speaker = request.user.speaker_profile
except ObjectDoesNotExist:
pass
else:
if not request.user.is_authenticated():
return redirect("account_login")
del request.session["pending-token"]
additional_speakers = ProposalBase.additional_speakers.through
additional_speakers._default_manager.filter(
speaker=speaker
).update(
speaker=existing_speaker
)
messages.info(request, _("You have been associated with all pending "
"talk proposals"))
return redirect("dashboard")
return redirect("speaker_create")