本文整理汇总了Python中user.models.User.confirm_membership_by_token方法的典型用法代码示例。如果您正苦于以下问题:Python User.confirm_membership_by_token方法的具体用法?Python User.confirm_membership_by_token怎么用?Python User.confirm_membership_by_token使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类user.models.User
的用法示例。
在下文中一共展示了User.confirm_membership_by_token方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: confirm_membership_by_token
# 需要导入模块: from user.models import User [as 别名]
# 或者: from user.models.User import confirm_membership_by_token [as 别名]
def confirm_membership_by_token(request):
"""
Confirm the membership with only the given token as authentication. Note that the URL to this view is hardcoded in
Focus which sends out emails/SMS with the URL and correct token.
"""
try:
token = request.GET['code']
actor = Actor.objects.get(family_youth_member_accepted_token=token)
youth_user = User.get_or_create_inactive(memberid=actor.memberid)
context = {
'token': token,
'youth_user': youth_user,
}
except (KeyError, Actor.DoesNotExist):
raise Http404
if request.method == 'GET':
return render(request, 'common/user/membership_confirmation.html', context)
elif request.method == 'POST':
try:
User.confirm_membership_by_token(token)
librato.increment('sherpa.medlemmer.familiemedlemskap.bekreft_ungdomsmedlem')
return redirect('%s?code=%s' % (reverse('user:confirm_membership_by_token'), token))
except:
context['confirmation_error'] = True
return render(request, 'common/user/membership_confirmation.html', context)