本文整理汇总了Python中accounts.models.User.get_by_uuid方法的典型用法代码示例。如果您正苦于以下问题:Python User.get_by_uuid方法的具体用法?Python User.get_by_uuid怎么用?Python User.get_by_uuid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类accounts.models.User
的用法示例。
在下文中一共展示了User.get_by_uuid方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: edit_user
# 需要导入模块: from accounts.models import User [as 别名]
# 或者: from accounts.models.User import get_by_uuid [as 别名]
def edit_user(uuid=None):
user = User.get_by_uuid(uuid)
form = forms.UserEditForm(obj=user)
# HACK: WTForms doesn't do dynamic lookup on instantiation ; must set choices here otherwise
# new users won't show up
form.organization.choices = forms.get_organization_choices()
if form.validate_on_submit():
# validate
if user:
# update db
data = form.data
# update
user.update(**data)
flash(messages.USER_UPDATED)
return redirect(url_for('accounts.users'))
ctx = {
'user': user,
'form': form,
}
return render_template('accounts/edit_user.html', **ctx)
示例2: account_settings
# 需要导入模块: from accounts.models import User [as 别名]
# 或者: from accounts.models.User import get_by_uuid [as 别名]
def account_settings():
"""
Account settings
"""
user = session.get('user', None)
form = forms.UserForm(obj=user)
if form.validate_on_submit():
# validate
if user:
# update db
data = form.data
# update
user.update(**data)
# update the session user
session['user'] = User.get_by_uuid(user.uuid)
flash(messages.ACCOUNT_UPDATED)
ctx = {
'account': session.get('user', None),
'form': form,
}
return render_template('accounts/edit_user.html', **ctx)
示例3: user_loader
# 需要导入模块: from accounts.models import User [as 别名]
# 或者: from accounts.models.User import get_by_uuid [as 别名]
def user_loader(user_id):
return User.get_by_uuid(user_id)
示例4: delete_user
# 需要导入模块: from accounts.models import User [as 别名]
# 或者: from accounts.models.User import get_by_uuid [as 别名]
def delete_user(uuid=None):
user = User.get_by_uuid(uuid)
if user:
user.remove()
return redirect(url_for('accounts.users'))