本文整理汇总了Python中daimaduan.models.base.User.save方法的典型用法代码示例。如果您正苦于以下问题:Python User.save方法的具体用法?Python User.save怎么用?Python User.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类daimaduan.models.base.User
的用法示例。
在下文中一共展示了User.save方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: signup_post
# 需要导入模块: from daimaduan.models.base import User [as 别名]
# 或者: from daimaduan.models.base.User import save [as 别名]
def signup_post():
form = SignupForm(request.forms)
if form.validate():
user = User()
form.populate_obj(user)
user.save()
login.login_user(user.id)
send_confirm_email(app.config, user.email)
return redirect('/active_email')
return {'form': form, 'token': request.csrf_token}
示例2: manage
# 需要导入模块: from daimaduan.models.base import User [as 别名]
# 或者: from daimaduan.models.base.User import save [as 别名]
def manage():
form = UserInfoForm(request.forms)
if form.validate():
if request.user:
request.user.username = form.username.data
return redirect('/')
else:
user = User(email=form.email.data, username=form.username.data,
is_email_confirmed=True)
user.save()
login.login_user(str(user.id))
session = get_session(request)
if 'email' in session:
del(session['email'])
return redirect('/')
return {'form': form, 'token': request.csrf_token}
示例3: manage
# 需要导入模块: from daimaduan.models.base import User [as 别名]
# 或者: from daimaduan.models.base.User import save [as 别名]
def manage():
form = UserInfoForm(request.form)
if form.validate():
if current_user.is_authenticated:
current_user.user.username = form.username.data
return redirect('/')
else:
user = User(email=form.email.data, username=form.username.data,
is_email_confirmed=True)
user.save()
user_mixin = LoginManagerUser(user)
login_user(user_mixin)
if 'email' in session:
del(session['email'])
return redirect('/')
return render_template('users/manage.html',
form=form)
示例4: signup
# 需要导入模块: from daimaduan.models.base import User [as 别名]
# 或者: from daimaduan.models.base.User import save [as 别名]
def signup():
form = SignupForm()
if request.method == 'GET':
return render_template('users/signup.html',
form=form)
else:
if form.validate_on_submit():
user = User()
form.populate_obj(user)
user.save()
bookmark = Bookmark(user=user,
title=u"%s 的收藏夹" % user.username,
is_default=True)
bookmark.save()
user_mixin = LoginManagerUser(user)
login_user(user_mixin)
send_confirm_email(current_app.config, user.email)
return redirect(url_for('site_app.index'))
return render_template('users/signup.html',
form=form)
示例5: finish_signup
# 需要导入模块: from daimaduan.models.base import User [as 别名]
# 或者: from daimaduan.models.base.User import save [as 别名]
def finish_signup():
form = UserInfoForm(request.form)
if form.validate():
if current_user.is_authenticated:
current_user.user.username = form.username.data
return redirect('/')
else:
user = User(email=form.email.data, username=form.username.data,
is_email_confirmed=True)
user.save()
bookmark = Bookmark(user=user,
title=u"%s 的收藏夹" % user.username,
is_default=True)
bookmark.save()
user_mixin = LoginManagerUser(user)
login_user(user_mixin)
flash(u"登录成功", category='info')
if 'email' in session:
del (session['email'])
return redirect('/')
return render_template('users/finish_signup.html',
form=form)