Exemple #1
0
def register():
    form = SignupForm()

    if form.validate_on_submit():
        user = User()
        form.populate_obj(user)
        user.activation_key = str(uuid.uuid4())

        db.session.add(user)
        db.session.commit()

        body = render_template("emails/register.html",
                               user=user)

        message = Message(subject=_(u"TZOS: Activate your account"),
                          body=body,
                          recipients=[user.email])
        mail.send(message)

        flash(_(u"Please check your email for instructions on "
                "how to activate your account."), "success")

        return redirect(url_for("frontend.index"))

    return render_template('account/register.html', form=form)
Exemple #2
0
def contact():

    if g.user:
        form = ContactForm(obj=g.user)
    else:
        form = ContactForm()

    if form and form.validate_on_submit():

        admins = User.query.filter(User.role == User.ADMIN)
        admin_emails = [admin.email for admin in admins]

        body = render_template("emails/contact.html",
                               name=form.display_name.data,
                               email=form.email.data,
                               text=form.text.data)

        message = Message(subject=_(u"TZOS: Contact from website"),
                          body=body,
                          recipients=admin_emails)
        mail.send(message)

        flash(_(u"Thanks for your message. We will try to reply you "
                "back as fast as possible."), "success")

        return redirect(url_for("frontend.index"))

    return render_template('contact.html', contact_form=form)
Exemple #3
0
def forgot_password():
    form = RecoverPasswordForm()

    if form.validate_on_submit():
        user = User.query.filter_by(email=form.email.data).first()

        if user:
            flash(_(u"Please check your email for instructions on "
                    "how to access your account."), "success")

            user.activation_key = str(uuid.uuid4())
            db.session.commit()

            body = render_template("emails/recover_password.html",
                                   user=user)

            message = Message(subject=_(u"Recover your password"),
                              body=body,
                              recipients=[user.email])
            mail.send(message)

            return redirect(url_for("frontend.index"))
        else:
            flash(_(u"Sorry, no user found for that email address."), "error")

    return render_template("account/recover_password.html", form=form)