本文整理汇总了Python中members.models.Member.display_from_email方法的典型用法代码示例。如果您正苦于以下问题:Python Member.display_from_email方法的具体用法?Python Member.display_from_email怎么用?Python Member.display_from_email使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类members.models.Member
的用法示例。
在下文中一共展示了Member.display_from_email方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
# 需要导入模块: from members.models import Member [as 别名]
# 或者: from members.models.Member import display_from_email [as 别名]
def create():
if 'app-key' not in request.headers:
response = jsonify({'code': 401, 'message': 'App-Key header is required.'})
response.status_code = 401
return response
application = Application.find_by_key(request.headers['app-key'])
if not application:
response = jsonify({'code': 401, 'message': 'Invalid App-key.'})
response.status_code = 401
return response
g.application = application
form = OrganizationCreateForm(request.form)
if not form.validate():
return form.errors_as_json()
plan = ApplicationPlan.find_by_id(form.application_plan_id.data)
if not plan:
form.errors['application_plan_id'] = ['No application plan found..']
return form.errors_as_json()
check = Organization.query.filter(Organization.name == form.name.data).first()
if check:
form.errors['name'] = ['Name is already taken.']
return form.errors_as_json()
organization = Organization(**{
'name': form.name.data,
'display': form.display.data,
'description': form.description.data,
'website': form.description.data,
'removed': form.removed.data,
'currency': form.currency.data.upper(),
'application_plan_id': form.application_plan_id.data,
'application_id': g.application.id
})
organization.save()
member = Member(**{
'display': Member.display_from_email(form.member_email.data),
'email': form.member_email.data,
'password': bcrypt.hashpw(form.member_password.data, bcrypt.gensalt()),
'organization_id': organization.id,
'status': 'MEMBER',
'admin': True
})
member.save()
return jsonify(organization.to_json()), 201