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


Python User.new_user方法代码示例

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


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

示例1: test_force_delete

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import new_user [as 别名]
    def test_force_delete(self):
        User.new_user("[email protected]", "test", "support", "$test_123123")
        db.session.commit()
        deleted = self.admin_client.delete("/api/0/_force_delete/",
                                           {"prefix": "$test", "tables": "user", "field": "name"}).json["deleted"]
        self.assertEqual(deleted["user"], 1)

        User.new_user("[email protected]", "testtest", "support")
        db.session.commit()
        deleted = self.admin_client.delete("/api/0/_force_delete/",
                                           {"prefix": "$test", "tables": "user"}).json["deleted"]
        self.assertEqual(deleted["user"], 1)

        deleted = self.admin_client.delete("/api/0/_force_delete/",
                                           {"prefix": "$test", "tables": "user"}).json["deleted"]
        self.assertEqual(deleted["user"], 0)
开发者ID:deti,项目名称:boss,代码行数:18,代码来源:test_utility.py

示例2: test_user_create

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import new_user [as 别名]
    def test_user_create(self):
        User.new_user("[email protected]", "123qwe", "admin", "test user")
        db.session.flush()
        with self.assertRaises(errors.UserAlreadyExists):
            User.new_user("[email protected]", "123qwe", "admin", "test user")
            db.session.flush()

        db.session.rollback()

        # conflict with user from fixtures
        with self.assertRaises(errors.UserAlreadyExists):
            User.new_user("[email protected]", "123qwe", "admin", "test user")
            db.session.flush()
        db.session.rollback()
开发者ID:deti,项目名称:boss,代码行数:16,代码来源:test_user.py

示例3: new_user

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import new_user [as 别名]
    def new_user(self, token, email, role, password=None, name=None):
        """
        Registration of new user.

        :param Email email: User email (Email_);
        :param str password: User Password. If the it is empty then the password
                             recovery email will be sent to the email.
        :param str role: User role.
        :param str name: User display name [optional]

        :returns dict user_info: User info.

        **Example**::

            {
                "user_info": {
                    {"name": "Super Admin",
                     "deleted": null,
                     "email": "[email protected]",
                     "role": {'localized_name': {'en': 'Administrator', 'ru': 'Администратор'},
                              'role_id': 'admin'}
                     "created": "2015-04-24T11:14:22"}
                }
            }

        """
        if not Role.validate(token.role, role):
            raise errors.UserInvalidRole()

        if token.role != Role.ADMIN and token.role == role:
            # user can administrate only users with low priority
            raise errors.UserInvalidRole()

        user_info = User.new_user(email, password, role, name=name)

        if not password:
            self.send_password_reset_email(email, request_base_url(), for_new_user=True)

        return {"user_info": display(user_info)}
开发者ID:deti,项目名称:boss,代码行数:41,代码来源:user.py

示例4: create_user

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import new_user [as 别名]
 def create_user(self, params=None):
     return User.new_user(**params)
开发者ID:deti,项目名称:boss,代码行数:4,代码来源:bootstrap.py


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