本文整理汇总了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)
示例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()
示例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)}
示例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)