本文整理汇总了Python中treemap.models.User.active方法的典型用法代码示例。如果您正苦于以下问题:Python User.active方法的具体用法?Python User.active怎么用?Python User.active使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类treemap.models.User
的用法示例。
在下文中一共展示了User.active方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_user
# 需要导入模块: from treemap.models import User [as 别名]
# 或者: from treemap.models.User import active [as 别名]
def create_user(request):
data = json.loads(request.body)
errors = {}
for field in REQ_FIELDS:
if field not in data:
errors[field] = [trans('This field is required')]
for inputfield in data:
if inputfield not in ALL_FIELDS:
errors[inputfield] = [trans('Unrecognized field')]
if errors:
raise ValidationError(errors)
dup_username = User.objects.filter(username=data['username'])
dup_email = User.objects.filter(email=data['email'])
if dup_username.exists():
return _conflict_response(trans('Username is already in use'))
if dup_email.exists():
# BE WARNED - The iOS application relies on this error message string.
# If you change this you WILL NEED TO ALTER CODE THERE AS WELL.
return _conflict_response(trans('Email is already in use'))
user = User(**data)
# Needed to properly hash the password
user.set_password(data['password'])
user.active = True
user.save()
RegistrationProfile.objects.create_profile(user)
return {'status': 'success', 'id': user.pk}
示例2: create_user
# 需要导入模块: from treemap.models import User [as 别名]
# 或者: from treemap.models.User import active [as 别名]
def create_user(request):
data = json.loads(request.body)
if 'allow_email_contact' not in data:
data['allow_email_contact'] = False
errors = {}
for field in REQ_FIELDS:
if field not in data:
errors[field] = [trans('This field is required')]
for inputfield in data:
if inputfield not in ALL_FIELDS:
errors[inputfield] = [trans('Unrecognized field')]
if errors:
raise ValidationError(errors)
dup_username = User.objects.filter(username=data['username'])
dup_email = User.objects.filter(email=data['email'])
if dup_username.exists():
return _conflict_response(trans('Username is already in use'))
if dup_email.exists():
return _conflict_response(trans('Email is already in use'))
user = User(**data)
# Needed to properly hash the password
user.set_password(data['password'])
user.active = True
user.save()
RegistrationProfile.objects.create_profile(user)
return {'status': 'success', 'id': user.pk}