Use a standard login handler
Is there any reason to not use the standard login decorator?
This commit is contained in:
parent
8cb7bcc021
commit
4a5e4dc6ea
1 changed files with 16 additions and 19 deletions
|
@ -71,29 +71,26 @@ def speaker_create_staff(request, pk):
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
def speaker_create_token(request, token):
|
def speaker_create_token(request, token):
|
||||||
speaker = get_object_or_404(Speaker, invite_token=token)
|
speaker = get_object_or_404(Speaker, invite_token=token)
|
||||||
request.session["pending-token"] = token
|
request.session["pending-token"] = token
|
||||||
if request.user.is_authenticated():
|
# check for speaker profile
|
||||||
# check for speaker profile
|
try:
|
||||||
try:
|
existing_speaker = request.user.speaker_profile
|
||||||
existing_speaker = request.user.speaker_profile
|
except ObjectDoesNotExist:
|
||||||
except ObjectDoesNotExist:
|
pass
|
||||||
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")
|
|
||||||
else:
|
else:
|
||||||
if not request.user.is_authenticated():
|
del request.session["pending-token"]
|
||||||
return redirect("account_login")
|
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")
|
return redirect("speaker_create")
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue