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


Python Email.send_confirmation方法代码示例

本文整理汇总了Python中models.Email.send_confirmation方法的典型用法代码示例。如果您正苦于以下问题:Python Email.send_confirmation方法的具体用法?Python Email.send_confirmation怎么用?Python Email.send_confirmation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Email的用法示例。


在下文中一共展示了Email.send_confirmation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: register

# 需要导入模块: from models import Email [as 别名]
# 或者: from models.Email import send_confirmation [as 别名]
def register():
    if request.method == 'GET':
        return render_template('users/register.html')
    try:
        user = User(request.form['email'], request.form['password'])
        DB.session.add(user)
        DB.session.commit()
    except ValueError:
        DB.session.rollback()
        flash("%s is not a valid email address." % request.form['email'], "error")
        return render_template('users/register.html')
    except IntegrityError:
        DB.session.rollback()
        flash("An account with this email already exists.", "error")
        return render_template('users/register.html')

    login_user(user, remember=True)

    sent = Email.send_confirmation(user.email, user.id)
    res = redirect(request.args.get('next', url_for('account')))
    if sent:
        res.set_cookie('pending-emails', user.email, max_age=10800)
        flash("Your {SERVICE_NAME} account was created successfully!".format(**settings.__dict__), 'success')
        flash("We've sent an email confirmation to {addr}. Please go there and click on the confirmation link before you can use your {SERVICE_NAME} account.".format(addr=current_user.email, **settings.__dict__), 'info')
    else:
        flash("Your account was set up, but we couldn't send a verification email to your address, please try doing it again manually later.", "warning")
    return res
开发者ID:arun-shrestha,项目名称:formspree,代码行数:29,代码来源:views.py

示例2: add_email

# 需要导入模块: from models import Email [as 别名]
# 或者: from models.Email import send_confirmation [as 别名]
def add_email():
    address = request.form['address'].lower().strip()
    res = redirect(url_for('account'))

    g.log = g.log.bind(address=address, account=current_user.email)

    if Email.query.get([address, current_user.id]):
        g.log.info('Failed to add email to account. Already registered.')
        flash(u'{} is already registered for your account.'.format(
            address), 'warning')
        return res
    try:
        g.log.info('Adding new email address to account.')
        sent = Email.send_confirmation(address, current_user.id)
        if sent:
            pending = request.cookies.get('pending-emails', '').split(',')
            pending.append(address)
            res.set_cookie('pending-emails', ','.join(pending), max_age=10800)
            flash(u"We've sent a message with a verification link to {}."
                  .format(address), 'info')
        else:
            flash(u"We couldn't sent you the verification email at {}. "
                  "Please try again later.".format(
                    address), 'error')
    except ValueError:
        flash(u'{} is not a valid email address.'.format(
            request.form['address']), 'warning')
    return res
开发者ID:Amstutz-IT,项目名称:formspree,代码行数:30,代码来源:views.py

示例3: add_email

# 需要导入模块: from models import Email [as 别名]
# 或者: from models.Email import send_confirmation [as 别名]
def add_email():
    address = request.form['address']
    res = redirect(url_for('account'))

    if Email.query.get([address, current_user.id]):
        flash("%s is already registered for your account." % address, 'warning')
        return res
    try:
        sent = Email.send_confirmation(address, current_user.id)
        if sent:
            pending = request.cookies.get('pending-emails', '').split(',')
            pending.append(address)
            res.set_cookie('pending-emails', ','.join(pending), max_age=10800)
            flash("We've sent a message with a verification link to %s." % address, 'info')
        else:
            flash("We couldn't sent you the verification email at %s. Please "
                  "try again later." % address, "error")
    except ValueError:
        flash("%s is not a valid email address." % request.form['address'], "warning")
    return res
开发者ID:arun-shrestha,项目名称:formspree,代码行数:22,代码来源:views.py


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