本文整理汇总了Python中forms.EmailForm.validate_on_submit方法的典型用法代码示例。如果您正苦于以下问题:Python EmailForm.validate_on_submit方法的具体用法?Python EmailForm.validate_on_submit怎么用?Python EmailForm.validate_on_submit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forms.EmailForm
的用法示例。
在下文中一共展示了EmailForm.validate_on_submit方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: re_verify
# 需要导入模块: from forms import EmailForm [as 别名]
# 或者: from forms.EmailForm import validate_on_submit [as 别名]
def re_verify():
form = EmailForm(request.form)
if form.validate_on_submit():
send_verification_email(form.get_user())
flash('Check your email for verification!')
return redirect(url_for('home'))
return render_template('no_email_verification.html', form=form)
示例2: sign_in
# 需要导入模块: from forms import EmailForm [as 别名]
# 或者: from forms.EmailForm import validate_on_submit [as 别名]
def sign_in():
form = EmailForm()
if form.validate_on_submit():
email = form.email.data
try:
user = User.get(email=email)
except User.DoesNotExist:
#print ('errorrrrrrr!')
return render_template('sign_in.html', form=form, login_error=True, reg_url=url_for('reg'))
else:
log_user(user)
return redirect(url_for('index'))
return render_template('sign_in.html', form=form, login_error=False, reg_url=url_for('reg'))
示例3: reset_password
# 需要导入模块: from forms import EmailForm [as 别名]
# 或者: from forms.EmailForm import validate_on_submit [as 别名]
def reset_password():
form = EmailForm()
if form.validate_on_submit():
user = mongo_db.users.User.find_one({'email' : form.email.data})
subject = "Succor password reset requested"
token = ts.dumps(user.email, salt='recover-key')
recover_url = url_for('reset_with_token', token=token, _external=True)
body = render_template('email/recover.txt', url=recover_url)
html = render_template('email/recover.html', url=recover_url)
send_email(subject, app.config['FROM_EMAIL_ADDRESS'], [user.email], body, html)
flash('Check your email for password reset link')
return redirect(url_for('home'))
return render_template('reset.html', form=form)
示例4: subscribe
# 需要导入模块: from forms import EmailForm [as 别名]
# 或者: from forms.EmailForm import validate_on_submit [as 别名]
def subscribe():
# TODO: conditional on method?
# TODO: fill with form data?
email_form = EmailForm()
mime_type = request.mimetype
# json
if mime_type == 'application/json':
return 'ok'
# html
else:
# Form submission
if email_form.validate_on_submit():
sub = Subscription(email_form.email.data)
db_session.add(sub)
db_session.commit()
flash("Thanks! You've been subscribed.")
return redirect(url_for('index'))
示例5: editemail
# 需要导入模块: from forms import EmailForm [as 别名]
# 或者: from forms.EmailForm import validate_on_submit [as 别名]
def editemail(id):
user = User.query.get(session['user_id'])
emailForm = EmailForm()
emailForm.email.default = user.email
if emailForm.validate_on_submit():
if (emailForm.email.data != emailForm.email.default):
users1 = user.query.all()
for user1 in users1:
if (emailForm.email.data == user1.email):
flash('Error: Email is already in use by another user')
return redirect(url_for('show', id=user.id))
user.email = emailForm.email.data
db.session.commit()
flash('Email Successfully Updated')
return redirect(url_for('show', id=user.id))
flash('Your original email, '+user.email+' has been saved')
return redirect(url_for('show', id=user.id))
flash('Error: Invalid Email Address')
return redirect(url_for('show', id=user.id))
示例6: email_someone
# 需要导入模块: from forms import EmailForm [as 别名]
# 或者: from forms.EmailForm import validate_on_submit [as 别名]
def email_someone():
"""
This function actually emails the message.
Make sure you change the from_address variable if you want to use this
functionality -- otherwise it won't work.
"""
form = EmailForm()
if request.method == 'POST' and form.validate_on_submit():
from_address = form.name.data + '@<YOURAPPID>.appspotmail.com'
to_address = form.recipient.data
subject = "%s <%s>" % (form.name.data, form.email.data)
message = ("From: %s\n\n"
"Email: %s\n\n"
"Message: %s") % (form.name.data, form.email.data,
form.message.data)
mail.send_mail(sender=from_address, to=to_address,
subject=subject, body=message)
status = 'success'
else:
status = 'failed'
return redirect(url_for('email_status', status=status))
示例7: index
# 需要导入模块: from forms import EmailForm [as 别名]
# 或者: from forms.EmailForm import validate_on_submit [as 别名]
def index():
email_form = EmailForm()
if email_form.validate_on_submit():
email_address = email_form.email.data
prev_user = User.query.filter_by(email = email_address).first()
if (prev_user is not None):
if (prev_user.verified):
flash('That email address has already been submitted and verified')
else:
#the situation where a previous email has already been seen
flash('That email address is already in our records but we will resend the verification email.')
return redirect(url_for('index'))
#NEED TO HANDLE CASE WHERE EMAIL ALREADY EXISTS
new_user = User(email=email_address, date_submitted=datetime.now())
db.session.add(new_user)
db.session.commit()
token = user.generate_confirmation_token()
send_verification_email('email/confirm', 'Confirm Your Account', user=user, token = token)
return redirect(url_for('thanks'))
return render_template('index.html', form = email_form)
示例8: show_main
# 需要导入模块: from forms import EmailForm [as 别名]
# 或者: from forms.EmailForm import validate_on_submit [as 别名]
def show_main():
form = EmailForm()
if form.validate_on_submit():
pass
return render_template('home.html', form = form)