本文整理汇总了Python中core.models.Person.setup_email_verification方法的典型用法代码示例。如果您正苦于以下问题:Python Person.setup_email_verification方法的具体用法?Python Person.setup_email_verification怎么用?Python Person.setup_email_verification使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.models.Person
的用法示例。
在下文中一共展示了Person.setup_email_verification方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: respond_with_new_user
# 需要导入模块: from core.models import Person [as 别名]
# 或者: from core.models.Person import setup_email_verification [as 别名]
def respond_with_new_user(self, request, next_url, desuprofile):
User = get_user_model()
password = create_temporary_password()
# Kompassi has stricter rules for username validation than Desusite
username = desuprofile.username.lower()
try:
valid_username(username)
except DjangoValidationError:
username = None
with transaction.atomic():
try:
User.objects.get(username=username)
except User.DoesNotExist:
# Username is free
pass
else:
# Username clash with an existing account, use safe username
username = None
if username is None:
username = "desuprofile_{id}".format(id=desuprofile.id)
user = User(
username=username,
is_active=True,
is_staff=False,
is_superuser=False,
)
user.set_password(password)
user.save()
person = Person(
first_name=desuprofile.first_name,
surname=desuprofile.last_name,
nick=desuprofile.nickname,
email=desuprofile.email,
phone=desuprofile.phone,
birth_date=datetime.strptime(desuprofile.birth_date, '%Y-%m-%d').date() if desuprofile.birth_date else None,
notes=u'Luotu Desuprofiilista',
user=user,
)
person.save()
connection = Connection(
id=int(desuprofile.id),
desuprofile_username=desuprofile.username,
user=user,
)
connection.save()
person.setup_email_verification(request)
if 'ipa_integration' in settings.INSTALLED_APPS:
from ipa_integration.utils import create_user
create_user(user, password)
messages.success(request, u'Sinulle on luotu Desuprofiiliisi liitetty Kompassi-tunnus. Tervetuloa Kompassiin!')
return respond_with_connection(request, next_url, connection)