本文整理汇总了Python中account.models.SignupCode.check方法的典型用法代码示例。如果您正苦于以下问题:Python SignupCode.check方法的具体用法?Python SignupCode.check怎么用?Python SignupCode.check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类account.models.SignupCode
的用法示例。
在下文中一共展示了SignupCode.check方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: is_open
# 需要导入模块: from account.models import SignupCode [as 别名]
# 或者: from account.models.SignupCode import check [as 别名]
def is_open(self):
code = self.request.REQUEST.get('code')
if code:
try:
self.signup_code = SignupCode.check(code)
except SignupCode.InvalidCode:
return settings.ACCOUNT_OPEN_SIGNUP
else:
return True
else:
return settings.ACCOUNT_OPEN_SIGNUP
示例2: clean_code
# 需要导入模块: from account.models import SignupCode [as 别名]
# 或者: from account.models.SignupCode import check [as 别名]
def clean_code(self):
try:
signup_code = SignupCode.check(self.cleaned_data.get("code"))
except SignupCode.InvalidCode:
if not settings.ACCOUNT_OPEN_SIGNUP:
raise forms.ValidationError(_("Signup code is invalid."))
else:
return None
else:
if not settings.ACCOUNT_OPEN_SIGNUP and signup_code is None:
raise forms.ValidationError(_("Code is required to signup."))
return signup_code
示例3: is_open
# 需要导入模块: from account.models import SignupCode [as 别名]
# 或者: from account.models.SignupCode import check [as 别名]
def is_open(self):
code = self.request.REQUEST.get("code")
if code:
try:
self.signup_code = SignupCode.check(code)
except SignupCode.InvalidCode:
if self.messages.get("invalid_signup_code"):
messages.add_message(
self.request,
self.messages["invalid_signup_code"]["level"],
self.messages["invalid_signup_code"]["text"] % {
"code": code
}
)
return settings.ACCOUNT_OPEN_SIGNUP
else:
return True
else:
return settings.ACCOUNT_OPEN_SIGNUP
示例4: is_open
# 需要导入模块: from account.models import SignupCode [as 别名]
# 或者: from account.models.SignupCode import check [as 别名]
def is_open(self):
code = self.request.REQUEST.get('code')
if code:
try:
self.signup_code = SignupCode.check(code)
except SignupCode.InvalidCode:
if self.messages.get('invalid_signup_code'):
messages.add_message(
self.request,
self.messages['invalid_signup_code']['level'],
self.messages['invalid_signup_code']['text'].format(**{
'code': code
})
)
return settings.ACCOUNT_OPEN_SIGNUP
else:
return True
else:
return settings.ACCOUNT_OPEN_SIGNUP
示例5: get
# 需要导入模块: from account.models import SignupCode [as 别名]
# 或者: from account.models.SignupCode import check [as 别名]
def get(self, *args, **kwargs):
if self.request.user.is_authenticated():
return redirect(default_redirect(self.request, settings.ACCOUNT_LOGIN_REDIRECT_URL))
code = self.request.GET.get("code")
try:
self.signup_code = SignupCode.check(code)
except SignupCode.InvalidCode:
if not settings.ACCOUNT_OPEN_SIGNUP:
return self.closed(code=code)
else:
if self.messages.get("invalid_signup_code"):
messages.add_message(
self.request,
self.messages["invalid_signup_code"]["level"],
self.messages["invalid_signup_code"]["text"] % {
"code": code
}
)
if not settings.ACCOUNT_OPEN_SIGNUP and self.signup_code is None:
return self.closed()
return super(SignupView, self).get(*args, **kwargs)