Add some example settings

master
Pierre Jaury 9 years ago
parent 6ab580b976
commit 6638f656e2

@ -31,6 +31,13 @@ class UserEditForm(Form):
submit = fields.SubmitField('Create')
class UserSettingsForm(Form):
displayed_name = fields.StringField('Displayed name')
spam_enabled = fields.BooleanField('Enable spam filter')
spam_threshold = fields.DecimalField('Spam filter sensitivity')
submit = fields.SubmitField('Save settings')
class UserPasswordForm(Form):
pw = fields.PasswordField('Password', [validators.DataRequired()])
pw2 = fields.PasswordField('Password check', [validators.DataRequired()])

@ -67,6 +67,12 @@ class User(Address):
reply_topic = db.Column(db.String(255), nullable=True, default=None)
reply_body = db.Column(db.Text(), nullable=True, default=None)
# Settings
displayed_name = db.Column(db.String(160), nullable=False, default="")
spam_enabled = db.Column(db.Boolean(), nullable=False, default=True)
spam_threshold = db.Column(db.Numeric(), nullable=False, default=5.0)
# Flask-login attributes
is_authenticated = True
is_active = True
is_anonymous = False

@ -1 +1,9 @@
{% extends "working.html" %}
{% extends "form.html" %}
{% block title %}
User settings
{% endblock %}
{% block subtitle %}
{{ user }}
{% endblock %}

@ -66,7 +66,19 @@ def user_delete(user_email):
@app.route('/user/usersettings/<user_email>', methods=['GET', 'POST'])
@flask_login.login_required
def user_settings(user_email):
return flask.render_template('user/settings.html')
user = utils.get_user(user_email)
form = forms.UserSettingsForm()
if form.validate_on_submit():
user.displayed_name = form.displayed_name.data
user.spam_enabled = form.spam_enabled.data
user.spam_threshold = form.spam_threshold.data
db.session.add(user)
db.session.commit()
flask.flash('Settings 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/settings.html', form=form, user=user)
@app.route('/user/password', methods=['GET', 'POST'], defaults={'user_email': None})

Loading…
Cancel
Save