Add an action confirmation form, related to #20

master
Pierre Jaury 8 years ago
parent 6bfdabe8c1
commit 5a69ada041

@ -31,6 +31,10 @@ class DestinationField(fields.SelectMultipleField):
raise validators.ValidationError("Invalid email address.")
class ConfirmationForm(Form):
submit = fields.SubmitField('Confirm')
class LoginForm(Form):
email = fields.StringField('E-mail', [validators.Email()])
pw = fields.PasswordField('Password', [validators.DataRequired()])

@ -0,0 +1,14 @@
{% extends "base.html" %}
{% block title %}
Confirm action
{% endblock %}
{% block subtitle %}
{{ action }}
{% endblock %}
{% block box_content %}
<p>You are about to {{ action }}. Please confirm your action.</p>
{{ macros.form(form) }}
{% endblock %}

@ -1,7 +1,25 @@
from freeposte.admin import models
from freeposte.admin import models, forms
import flask
import flask_login
import functools
def confirmation_required(action):
""" View decorator that asks for a confirmation first.
"""
def inner(function):
@functools.wraps(function)
def wrapper(*args, **kwargs):
form = forms.ConfirmationForm()
if form.validate_on_submit():
return function(*args, **kwargs)
return flask.render_template(
"confirm.html", action=action.format(*args, **kwargs),
form=form
)
return wrapper
return inner
def get_domain_admin(domain_name):

Loading…
Cancel
Save