本文整理汇总了Python中models.users.Users.add_new_user方法的典型用法代码示例。如果您正苦于以下问题:Python Users.add_new_user方法的具体用法?Python Users.add_new_user怎么用?Python Users.add_new_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.users.Users
的用法示例。
在下文中一共展示了Users.add_new_user方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models.users import Users [as 别名]
# 或者: from models.users.Users import add_new_user [as 别名]
def post(self):
name = self.request.get('name')
email = self.request.get('email')
password = self.request.get('password')
status = 200
if name and email and password:
email_validation_pattern = "(^[a-zA-Z0-9_.+-][email protected][a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)"
if re.match(email_validation_pattern, email):
user = Users.add_new_user(name, email, password)
if user['created']:
html = self.jinja_environment.get_template('commons/register_modal_success.html').render()
json_response = {
'html': html
}
self.send_email(to=email, user_id=user['user_id'], confirmation_code=user['confirmation_code'])
else:
status = 400
json_response = user
else:
status = 400
json_response = {
'created': False,
'title': 'The email is not valid',
'message': 'Please enter a valid email address'
}
else:
status = 400
json_response = {}
if not name:
json_response.update({
'title': 'The Name field is required',
'message': 'Please fill in your name in order to continue.'
})
if not email:
json_response.update({
'title': 'The Email field is required',
'message': 'Please send us a valid email address, thanks!'
})
if not password:
json_response.update({
'title': 'Please type in a password',
'message': 'Please fill in your password in order to continue.'
})
self.json_response(status_code=status, **json_response)