当前位置: 首页>>代码示例>>Python>>正文


Python User.save方法代码示例

本文整理汇总了Python中treemap.models.User.save方法的典型用法代码示例。如果您正苦于以下问题:Python User.save方法的具体用法?Python User.save怎么用?Python User.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在treemap.models.User的用法示例。


在下文中一共展示了User.save方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_user

# 需要导入模块: from treemap.models import User [as 别名]
# 或者: from treemap.models.User import save [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}
开发者ID:PyBulls,项目名称:OTM2,代码行数:37,代码来源:user.py

示例2: create_user

# 需要导入模块: from treemap.models import User [as 别名]
# 或者: from treemap.models.User import save [as 别名]
def create_user(*args, **kwargs):
    # Clearly this is just getting the api working
    # it shouldn't stay here when real user stuff happens
    user = User(username=kwargs["username"], email=kwargs["email"])
    user.set_password(kwargs["password"])
    user.save()

    return user
开发者ID:jvgriffis,项目名称:OTM2,代码行数:10,代码来源:views.py

示例3: _create_test_user

# 需要导入模块: from treemap.models import User [as 别名]
# 或者: from treemap.models.User import save [as 别名]
    def _create_test_user(self):
        global userUUID

        username = 'autotest%s' % userUUID
        email = '%[email protected]' % username
        userUUID += 1

        User.objects.filter(email=email).delete()

        u = User(username=username, email=email)
        u.set_password(username)
        u.save()
        setattr(u, 'plain_password', username)

        return u
开发者ID:jvgriffis,项目名称:OTM2,代码行数:17,代码来源:basic.py

示例4: create_user

# 需要导入模块: from treemap.models import User [as 别名]
# 或者: from treemap.models.User import save [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}
开发者ID:summer-of-open-source,项目名称:OTM2,代码行数:38,代码来源:user.py

示例5: make_plain_user

# 需要导入模块: from treemap.models import User [as 别名]
# 或者: from treemap.models.User import save [as 别名]
def make_plain_user(username, password='password'):
    user = User(username=username, email='%[email protected]e.com' % username)
    user.set_password(password)  # hashes password, allowing authentication
    user.save()

    return user
开发者ID:cleberar38,项目名称:otm-core,代码行数:8,代码来源:__init__.py


注:本文中的treemap.models.User.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。