mirror of
https://github.com/Mailu/Mailu.git
synced 2025-02-21 19:19:39 +02:00
Add an action confirmation form, related to #20
This commit is contained in:
parent
6bfdabe8c1
commit
5a69ada041
@ -31,6 +31,10 @@ class DestinationField(fields.SelectMultipleField):
|
|||||||
raise validators.ValidationError("Invalid email address.")
|
raise validators.ValidationError("Invalid email address.")
|
||||||
|
|
||||||
|
|
||||||
|
class ConfirmationForm(Form):
|
||||||
|
submit = fields.SubmitField('Confirm')
|
||||||
|
|
||||||
|
|
||||||
class LoginForm(Form):
|
class LoginForm(Form):
|
||||||
email = fields.StringField('E-mail', [validators.Email()])
|
email = fields.StringField('E-mail', [validators.Email()])
|
||||||
pw = fields.PasswordField('Password', [validators.DataRequired()])
|
pw = fields.PasswordField('Password', [validators.DataRequired()])
|
||||||
|
14
admin/freeposte/admin/templates/confirm.html
Normal file
14
admin/freeposte/admin/templates/confirm.html
Normal file
@ -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
|
||||||
import flask_login
|
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):
|
def get_domain_admin(domain_name):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user