本文整理汇总了Python中forms.EditProfileForm.validate_on_submit方法的典型用法代码示例。如果您正苦于以下问题:Python EditProfileForm.validate_on_submit方法的具体用法?Python EditProfileForm.validate_on_submit怎么用?Python EditProfileForm.validate_on_submit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forms.EditProfileForm
的用法示例。
在下文中一共展示了EditProfileForm.validate_on_submit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: edit_profile
# 需要导入模块: from forms import EditProfileForm [as 别名]
# 或者: from forms.EditProfileForm import validate_on_submit [as 别名]
def edit_profile():
#form = EditProfileForm(g.user.nickname)
form = EditProfileForm()
avatar_form = EditAvatarForm()
cover_form = EditCoverForm()
# ----- If form is used
print 'EP', form.validate_on_submit()
if form.validate_on_submit():
g.user.name = form.name.data
g.user.show_email = form.show_email.data
g.user.bio = form.bio.data
g.user.sex = form.sex.data
g.user.slogan = form.slogan.data
g.user.status = form.status.data
g.user.location = form.location.data
db.session.add(g.user)
db.session.commit()
flash('Your changes have been saved.', 'success')
return redirect(url_for('edit_profile'))
else:
form.name.data = g.user.name
form.show_email.data = g.user.show_email
form.bio.data = g.user.bio
form.sex.data = g.user.sex
form.slogan.data = g.user.slogan
form.status.data = g.user.status
form.location.data = g.user.location
return render_template(
"site/%s/edit_profile.html" % (cordon.config['TEMPLATE']),
user = g.user,
form = form,
avatar_form = avatar_form,
cover_form = cover_form,
)
示例2: edit_profile
# 需要导入模块: from forms import EditProfileForm [as 别名]
# 或者: from forms.EditProfileForm import validate_on_submit [as 别名]
def edit_profile():
form = EditProfileForm()
if form.validate_on_submit():
current_user.first_name = form.first_name.data
current_user.last_name = form.last_name.data
current_user.location = form.location.data
current_user.national_id = form.national_id.data
current_user.phone_number = form.phone_number.data
current_user.marital_status = form.marital_status.data
current_user.gender = form.gender.data
current_user.d_o_b = form.d_o_b.data
db.session.add(current_user)
flash('Your profile has been updated.')
return redirect(url_for('.user', username=current_user.username))
form.first_name.data = current_user.first_name
form.last_name.data = current_user.last_name
form.location.data = current_user.location
form.national_id.data = current_user.national_id
form.phone_number.data = current_user.phone_number
form.marital_status.data = current_user.marital_status
form.gender.data = current_user.gender
form.d_o_b.data = current_user.d_o_b
return render_template('edit_profile.html', form=form, user=user)
示例3: edit
# 需要导入模块: from forms import EditProfileForm [as 别名]
# 或者: from forms.EditProfileForm import validate_on_submit [as 别名]
def edit():
form = EditProfileForm()
if form.validate_on_submit():
g.user.emailReminders = form.emailReminders.data
g.user.pmReminders = form.pmReminders.data
if not form.email.data:
g.user.email = None
g.user.emailConfirmed = None
db.session.add(g.user)
db.session.commit()
flash('Profile Successfully Updated.', 'info')
return redirect(url_for('edit'))
if form.email.data == g.user.email and g.user.emailConfirmed:
db.session.add(g.user)
db.session.commit()
flash('Profile Successfully Updated.', 'info')
return redirect(url_for('edit'))
provisionalEmail = form.email.data
if g.user.email is None or g.user.emailConfirmed == False:
g.user.email = provisionalEmail
g.user.emailConfirmed = False
db.session.add(g.user)
db.session.commit()
message.send_email('Confirm Your Account', [provisionalEmail], 'confirmation',
user=g.user, token=g.user.generate_confirmation_token(email=provisionalEmail))
flash('A confirmation message has been sent to you. Please check your spam or junk folder.', 'warning')
return redirect(url_for('edit'))
form.email.data = g.user.email
form.emailReminders.data = g.user.emailReminders
form.pmReminders.data = g.user.pmReminders
return render_template('editprofile.html',
form=form,
user=g.user)
示例4: edit_profile
# 需要导入模块: from forms import EditProfileForm [as 别名]
# 或者: from forms.EditProfileForm import validate_on_submit [as 别名]
def edit_profile():
form = EditProfileForm()
c = Config()
if form.validate_on_submit():
current_user.bio = form.bio.data
current_user.address = form.address.data
current_user.phone_number = form.phone_number.data
current_user.website = form.website.data
current_user.public_email = form.email.data
current_user.f1 = form.featured1.data
if form.image.data:
filename = form.image.data.filename
get_queue().enqueue(process_image,
type='image',
filename=filename,
data =form.image.data.read(),
user_id=current_user.id)
if form.pdf.data:
filename = form.pdf.data.filename
get_queue().enqueue(process_image,
type='pdf',
filename=filename,
data =form.pdf.data.read(),
user_id=current_user.id)
db.session.commit()
return redirect(url_for('vendor.view_profile'))
form.bio.data = current_user.bio
form.address.data = current_user.address
form.phone_number.data = current_user.phone_number
form.website.data = current_user.website
form.email.data = current_user.public_email
form.featured1.data = current_user.f1
return render_template('vendor/edit_profile.html', form=form)
示例5: edit
# 需要导入模块: from forms import EditProfileForm [as 别名]
# 或者: from forms.EditProfileForm import validate_on_submit [as 别名]
def edit():
form = EditProfileForm()
if form.validate_on_submit():
current_user.firstname = form.firstname.data
current_user.lastname = form.lastname.data
current_user.address = form.address.data
current_user.city = form.city.data
current_user.state = form.state.data
current_user.zipcode = form.zipcode.data
current_user.country = form.country.data
current_user.about_me = form.about_me.data
current_user.user_disabled = form.user_disabled.data
model.session.add(current_user)
model.session.commit()
flash('Your changes have been saved!')
return redirect(url_for('edit'))
#renders the fields with data from database
else:
form.firstname.data= current_user.firstname
form.lastname.data= current_user.lastname
form.address.data= current_user.address
form.city.data= current_user.city
form.state.data= current_user.state
form.zipcode.data= current_user.zipcode
form.country.data= current_user.country
form.about_me.data= current_user.about_me
form.user_disabled.data= current_user.user_disabled
return render_template("edit_profile.html",
form=form)
示例6: edit
# 需要导入模块: from forms import EditProfileForm [as 别名]
# 或者: from forms.EditProfileForm import validate_on_submit [as 别名]
def edit():
form = EditProfileForm()
if form.validate_on_submit():
pic_file = request.files[form.profile_pic.name]
if pic_file and allowed_file(pic_file.filename):
filename = secure_filename(pic_file.filename)
folder = os.path.join(current_app.config['UPLOAD_FOLDER'],
PROFILE_PIC_UPLOAD_SUBFOLDER)
if not os.path.exists(folder):
os.makedirs(folder)
pic_file.save(os.path.join(folder, filename))
current_user.profile_pic_url = url_for('.profile_pic',
filename=filename)
current_user.name = form.name.data
current_user.email = form.email.data
db.session.add(current_user)
db.session.commit()
flash("Account information saved successfully", "success")
return redirect(url_for('.show'))
if request.method == 'GET':
form.name.data = current_user.name
form.email.data = current_user.email
return render_template('account/edit.html', form=form)
示例7: edit_profile
# 需要导入模块: from forms import EditProfileForm [as 别名]
# 或者: from forms.EditProfileForm import validate_on_submit [as 别名]
def edit_profile():
form = EditProfileForm()
if form.validate_on_submit():
current_user.name = form.name.data
db.session.add(current_user)
flash('Your profile has been updated.')
return redirect(url_for('.user', username=current_user.username))
form.name.data = current_user.name
return render_template('apartment/edit_profile.html', form=form)
示例8: editprofile
# 需要导入模块: from forms import EditProfileForm [as 别名]
# 或者: from forms.EditProfileForm import validate_on_submit [as 别名]
def editprofile():
form = EditProfileForm(obj=current_user)
# form.populate_obj(user)
if form.validate_on_submit():
return render_template('editprofile.html', title="Username", user=current_user, form=form)
return render_template('editprofile.html', title="Username", user=current_user, form=form)
示例9: edit_profile
# 需要导入模块: from forms import EditProfileForm [as 别名]
# 或者: from forms.EditProfileForm import validate_on_submit [as 别名]
def edit_profile():
user = User.query.get(session['user_id'])
form = EditProfileForm(obj=user)
form.populate_obj(user)
if form.validate_on_submit():
print user
db.session.add(user)
print "session add user"
db.session.commit()
print "session commit user"
return redirect(url_for('profile'))
return render_template('edit_profile.html', form=form)
示例10: edit_profile
# 需要导入模块: from forms import EditProfileForm [as 别名]
# 或者: from forms.EditProfileForm import validate_on_submit [as 别名]
def edit_profile():
form = EditProfileForm()
if form.validate_on_submit():
current_user.name = form.name.data
current_user.location = form.location.data
current_user.about_me = form.about_me.data
DB.update_user_profile(current_user)
return redirect(url_for('.user', username=current_user.username))
form.name.data = current_user.name
form.location.data = current_user.location
form.about_me.data = current_user.about_me
return render_template('edit_profile.html', form=form)
示例11: editUserInfo
# 需要导入模块: from forms import EditProfileForm [as 别名]
# 或者: from forms.EditProfileForm import validate_on_submit [as 别名]
def editUserInfo():
form = EditProfileForm()
user=current_user
if form.validate_on_submit():
current_user.name = form.name.data
current_user.location = form.location.data
current_user.about_me = form.about_me.data
current_user.contactMe = form.mycontact.data
current_user.avatar = form.avatar.data
db.session.add(current_user)
db.session.commit()
flash(u'修改个人信息成功')
return render_template('info/editUserInfo.html', form=form, user=user)
示例12: edit_profile
# 需要导入模块: from forms import EditProfileForm [as 别名]
# 或者: from forms.EditProfileForm import validate_on_submit [as 别名]
def edit_profile():
form = EditProfileForm()
if form.validate_on_submit():
current_user.name = form.name.data
current_user.location = form.location.data
current_user.about_me = form.about_me.data
db.session.add(current_user)
flash("Your profile has been updated .")
return redirect(url_for('main.user', username=current_user.username))
form.name.data = current_user.name
form.location.data = current_user.location
form.about_me.data = current_user.about_me
return render_template('edit_profile.html', form=form)
示例13: edit_profile
# 需要导入模块: from forms import EditProfileForm [as 别名]
# 或者: from forms.EditProfileForm import validate_on_submit [as 别名]
def edit_profile():
form = EditProfileForm(g.user.nickname)
flash(g.user.nickname)
if form.validate_on_submit():
print 'inside validate_on_submit'
g.user.about_me = form.about_me.data
g.user.nickname = form.nickname.data
db.session.add(g.user)
db.session.commit()
flash("About me save !")
return redirect(url_for('index'))
return render_template('edit_profile.html', form=form)
示例14: editprofile
# 需要导入模块: from forms import EditProfileForm [as 别名]
# 或者: from forms.EditProfileForm import validate_on_submit [as 别名]
def editprofile():
form = EditProfileForm(current_user.name)
if form.validate_on_submit():
current_user.name = form.name.data
current_user.email = form.email.data
current_user.phone = form.phone.data
db_session.add(current_user)
db_session.commit()
flash('Your changes have been saved.')
return redirect(url_for('editprofile'))
elif request.method != "POST":
form.name.data = current_user.name
form.email.data = current_user.email
form.phone.data = current_user.phone
return render_template('editprofile.html', form=form)
示例15: edit_profile
# 需要导入模块: from forms import EditProfileForm [as 别名]
# 或者: from forms.EditProfileForm import validate_on_submit [as 别名]
def edit_profile():
form = EditProfileForm(g.user.username)
if form.validate_on_submit():
g.user.username = form.username.data
g.user.about = form.about.data
db.session.add(g.user)
db.session.commit()
flash('Your changes have been saved.')
return redirect(url_for('user', username = g.user.username))
else:
form.username.data = g.user.username
form.about.data = g.user.about
return render_template('edit_profile.html',
title = 'Edit Profile',
form = form)