本文整理汇总了Python中profiles.models.Profile.has_beta_key方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.has_beta_key方法的具体用法?Python Profile.has_beta_key怎么用?Python Profile.has_beta_key使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类profiles.models.Profile
的用法示例。
在下文中一共展示了Profile.has_beta_key方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: activate_account
# 需要导入模块: from profiles.models import Profile [as 别名]
# 或者: from profiles.models.Profile import has_beta_key [as 别名]
def activate_account(request,account_activation_key = None):
csrfContext = RequestContext(request)
try:
key = ConfirmationKey.objects.get(key = account_activation_key,function = 'signup')
except ConfirmationKey.DoesNotExist:
request.flash["error"] = _(u"The supplied key does not exist.")
raise Http404
if not key.is_valid:
return render_to_response('information.html',{'title':_(u"User account already activated"),'text':_(u"It seems that your user account has already been activated.")},csrfContext)
if User.objects.filter(email = key.email,profile__isnull = False).count():
return render_to_response('information.html',{'title':_(u"A user with this e-mail address already exists."),'text':_(u"We are sorry, but the e-mail address you have chosen is already associated to a user account.")},csrfContext)
else:
data = key.get_data()
user = User()
profile = Profile()
obsolete_users = User.objects.filter(email = key.email)
for obsolete_user in obsolete_users:
obsolete_user.email = ''
obsolete_user.save()
user.username = generate_random_key()
user.email = key.email
user.set_password(data["password"])
notify_staff({'title':'New user account','text':"Somebody with email %s has created a new user account." % key.email},notification_object = user)
user.save()
profile.user = user
profile.has_verified_email = True
profile.is_active = True
profile.has_beta_key = True
profile.save()
#We remove the sensitive password from the key's data.
del data["password"]
key.set_data(data)
key.invalidate()
_directly_login_user(request,profile.user)
csrfContext = RequestContext(request)
next_url = None
if 'next_url' in data:
next_url = data['next_url']
return render_to_response('profiles/activate_account.html', {'next_url':next_url},csrfContext)