Store the state of reply and forward settings being enabled

master
Pierre Jaury 9 years ago
parent a1d0eca859
commit 9efc798246

@ -42,15 +42,15 @@ class UserPasswordForm(Form):
class UserForwardForm(Form):
forward_enabled = fields.BooleanField('Enable forwarding', default=False)
forward = fields.StringField(
forward_enabled = fields.BooleanField('Enable forwarding')
forward_destination = fields.StringField(
'Destination', [validators.Optional(), validators.Email()]
)
submit = fields.SubmitField('Update')
class UserReplyForm(Form):
reply_enabled = fields.BooleanField('Enable reply', default=False)
reply_enabled = fields.BooleanField('Enable automatic reply')
reply_subject = fields.StringField('Reply subject')
reply_body = fields.StringField('Reply body', widget=widgets.TextArea())
submit = fields.SubmitField('Update')

@ -87,7 +87,9 @@ class User(Email):
enable_pop = db.Column(db.Boolean(), nullable=False, default=True)
# Filters
forward = db.Column(db.String(160), nullable=True, default=None)
forward_enabled = db.Column(db.Boolean(), nullable=False, default=False)
forward_destination = db.Column(db.String(255), nullable=True, default=None)
reply_enabled = db.Column(db.Boolean(), nullable=False, default=False)
reply_subject = db.Column(db.String(255), nullable=True, default=None)
reply_body = db.Column(db.Text(), nullable=True, default=None)

@ -14,8 +14,6 @@ Global administrators
<tr>
<th>Actions</th>
<th>Email</th>
<th>Created</th>
<th>Last edit</th>
</tr>
{% for admin in admins %}
<tr>
@ -23,8 +21,6 @@ Global administrators
<a href="{{ url_for('.admin_delete', admin=admin.email) }}" onclick="return confirm('Are you sure?')" title="Delete"><i class="fa fa-trash"></i></a>
</td>
<td>{{ admin }}</td>
<td>{{ admin.created_at }}</td>
<td>{{ admin.updated_at or '' }}</td>
</tr>
{% endfor %}
</tbody>

@ -18,8 +18,6 @@ Manager list
<tr>
<th>Actions</th>
<th>Email</th>
<th>Created</th>
<th>Last edit</th>
</tr>
{% for manager in domain.managers %}
<tr>
@ -27,8 +25,6 @@ Manager list
<a href="{{ url_for('.manager_delete', manager=manager.email) }}" onclick="return confirm('Are you sure?')" title="Delete"><i class="fa fa-trash"></i></a>
</td>
<td>{{ manager }}</td>
<td>{{ manager.created_at }}</td>
<td>{{ manager.updated_at or '' }}</td>
</tr>
{% endfor %}
</tbody>

@ -12,11 +12,10 @@ Forward emails
<form class="form" method="post" role="form">
{{ form.hidden_tag() }}
{{ macros.form_field(form.forward_enabled,
onchange="if(this.checked){$('#forward').removeAttr('disabled')}
else{$('#forward').attr('disabled', '').val('')}",
**{("checked" if user.forward else "unchecked"): ""}) }}
{{ macros.form_field(form.forward,
**{("enabled" if user.forward else "disabled"): ""}) }}
onchange="if(this.checked){$('#forward_destination').removeAttr('disabled')}
else{$('#forward_destination').attr('disabled', '')}") }}
{{ macros.form_field(form.forward_destination,
**{("enabled" if user.forward_enabled else "disabled"): ""}) }}
{{ macros.form_field(form.submit) }}
</form>
{% endblock %}

@ -13,8 +13,7 @@ Automatic reply
{{ form.hidden_tag() }}
{{ macros.form_field(form.reply_enabled,
onchange="if(this.checked){$('#reply_subject,#reply_body').removeAttr('disabled')}
else{$('#reply_subject,#reply_body').attr('disabled', '').val('')}",
**{("checked" if user.reply_subject else "unchecked"): ""}) }}
else{$('#reply_subject,#reply_body').attr('disabled', '')}") }}
{{ macros.form_field(form.reply_subject,
**{("enabled" if user.reply_subject else "disabled"): ""}) }}
{{ macros.form_field(form.reply_body, rows=10,

@ -10,11 +10,11 @@ import wtforms_components
@app.route('/fetch/list/<user_email>', methods=['GET'])
@flask_login.login_required
def fetch_list(user_email):
user = utils.get_user(user_email, True)
user = utils.get_user(user_email)
return flask.render_template('fetch/list.html', user=user)
@app.route('/fetch/list', methods=['GET', 'POST'], defaults={'user_email': None})
@app.route('/fetch/create', methods=['GET', 'POST'], defaults={'user_email': None})
@app.route('/fetch/create/<user_email>', methods=['GET', 'POST'])
@flask_login.login_required
def fetch_create(user_email):

@ -1,14 +1,10 @@
require ["variables", "vacation", "vnd.dovecot.extdata"];
if string :is "${extdata.reply_subject}" "" {
} else {
if ${extdata.reply_enabled} {
vacation :days 1 :subject "${extdata.reply_subject}" "${extdata.reply_body}";
}
if string :is "${extdata.forward}" "" {
} else {
redirect "${extdata.forward}";
if ${extdata.forward_enabled} {
redirect "${extdata.forward_destination}";
keep;
}

Loading…
Cancel
Save