Add the auto-reply feature in the admin panel

master
Pierre Jaury 9 years ago
parent e1c34c5984
commit b07158c256

@ -42,6 +42,12 @@ class UserForwardForm(Form):
submit = fields.SubmitField('Update') submit = fields.SubmitField('Update')
class UserReplyForm(Form):
reply_subject = fields.StringField('Reply subject')
reply_body = fields.StringField('Reply body', widget=widgets.TextArea())
submit = fields.SubmitField('Update')
class AliasCreateForm(Form): class AliasCreateForm(Form):
localpart = fields.StringField('Alias', [validators.DataRequired()]) localpart = fields.StringField('Alias', [validators.DataRequired()])
destination = fields.StringField('Destination', widget=widgets.TextArea()) destination = fields.StringField('Destination', widget=widgets.TextArea())

@ -60,9 +60,13 @@ class User(Address):
domain = db.relationship(Domain, backref='users') domain = db.relationship(Domain, backref='users')
password = db.Column(db.String(255), nullable=False) password = db.Column(db.String(255), nullable=False)
quota_bytes = db.Column(db.Integer(), nullable=False, default=10**9) quota_bytes = db.Column(db.Integer(), nullable=False, default=10**9)
forward = db.Column(db.String(160), nullable=True, default=None)
global_admin = db.Column(db.Boolean(), nullable=False, default=False) global_admin = db.Column(db.Boolean(), nullable=False, default=False)
# Filters
forward = db.Column(db.String(160), nullable=True, default=None)
reply_topic = db.Column(db.String(255), nullable=True, default=None)
reply_body = db.Column(db.Text(), nullable=True, default=None)
is_authenticated = True is_authenticated = True
is_active = True is_active = True
is_anonymous = False is_anonymous = False

@ -19,8 +19,8 @@
</a> </a>
</li> </li>
<li> <li>
<a href="{{ url_for('user_vacation') }}"> <a href="{{ url_for('user_reply') }}">
<i class="fa fa-plane"></i> <span>Vacation</span> <i class="fa fa-plane"></i> <span>Auto-reply</span>
</a> </a>
</li> </li>
<li> <li>

@ -0,0 +1,9 @@
{% extends "form.html" %}
{% block title %}
Automatic reply
{% endblock %}
{% block subtitle %}
{{ user }}
{% endblock %}

@ -1 +0,0 @@
{% extends "working.html" %}

@ -103,14 +103,25 @@ def user_forward(user_email):
if user_email: if user_email:
return flask.redirect( return flask.redirect(
flask.url_for('user_list', domain_name=user.domain.name)) flask.url_for('user_list', domain_name=user.domain.name))
return flask.render_template('user/forward.html', form=form, user=useré) return flask.render_template('user/forward.html', form=form, user=user)
@app.route('/user/vacation', methods=['GET', 'POST'], defaults={'user_email': None}) @app.route('/user/reply', methods=['GET', 'POST'], defaults={'user_email': None})
@app.route('/user/vacation<user_email>', methods=['GET', 'POST']) @app.route('/user/reply/<user_email>', methods=['GET', 'POST'])
@flask_login.login_required @flask_login.login_required
def user_vacation(user_email): def user_reply(user_email):
return flask.render_template('user/vacation.html') user = utils.get_user(user_email)
form = forms.UserReplyForm()
if form.validate_on_submit():
user.reply_subject = form.reply_subject.data
user.reply_body = form.reply_body.data
db.session.add(user)
db.session.commit()
flask.flash('Auto-reply message updated for %s' % user)
if user_email:
return flask.redirect(
flask.url_for('user_list', domain_name=user.domain.name))
return flask.render_template('user/reply.html', form=form, user=user)
@app.route('/user/fetchmail', methods=['GET', 'POST'], defaults={'user_email': None}) @app.route('/user/fetchmail', methods=['GET', 'POST'], defaults={'user_email': None})

Loading…
Cancel
Save