当前位置: 首页>>代码示例>>Python>>正文


Python EmailForm.validate_on_submit方法代码示例

本文整理汇总了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) 
开发者ID:succor-app,项目名称:study_buddy,代码行数:10,代码来源:views.py

示例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'))
开发者ID:faith0811,项目名称:chart3,代码行数:15,代码来源:views.py

示例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)
开发者ID:succor-app,项目名称:study_buddy,代码行数:17,代码来源:views.py

示例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'))
开发者ID:decacycle,项目名称:etd,代码行数:21,代码来源:application.py

示例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))
开发者ID:kmalfatti,项目名称:game-exchange,代码行数:21,代码来源:app.py

示例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))
开发者ID:ryangavin,项目名称:stevens_hackny2011,代码行数:24,代码来源:views.py

示例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)
开发者ID:murphsp1,项目名称:WebDevelopmentWithFlask,代码行数:25,代码来源:email_collector.py

示例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)
开发者ID:tonylau,项目名称:GUTS_site,代码行数:7,代码来源:views.py


注:本文中的forms.EmailForm.validate_on_submit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。