Exemplo n.º 1
0
def send_confirmation_email(session_store, schema):
    try:
        confirmation_email = ConfirmationEmail(
            session_store, schema, serialised_email=request.args.get("email"))
    except (ConfirmationEmailLimitReached, ConfirmationEmailNotEnabled):
        return redirect(url_for(".get_thank_you"))

    if request.method == "POST":
        if confirmation_email.form.validate():
            return redirect(
                url_for(
                    ".confirm_confirmation_email",
                    email=confirmation_email.get_url_safe_serialized_email(),
                ))

        logger.info(
            "email validation error",
            error_message=str(confirmation_email.form.errors["email"][0]),
        )

    return render_template(
        template="confirmation-email",
        content=confirmation_email.get_context(),
        hide_sign_out_button=True,
        page_title=confirmation_email.get_page_title(),
    )
def send_confirmation_email():
    if not get_session_store().session_data.confirmation_email_count:
        raise NotFound

    try:
        confirmation_email = ConfirmationEmail()
    except ConfirmationEmailLimitReached:
        return redirect(url_for("post_submission.get_thank_you"))

    if request.method == "POST" and confirmation_email.form.validate():
        confirmation_email.handle_post()
        return redirect(
            url_for(
                "post_submission.get_confirmation_email_sent",
                email=confirmation_email.get_url_safe_serialized_email(),
            ))

    return render_template(
        template="confirmation-email",
        content=confirmation_email.get_context(),
        hide_signout_button=True,
        page_title=confirmation_email.get_page_title(),
    )