Prefill user forms

master
Pierre Jaury 9 years ago
parent 6638f656e2
commit a5279b7757

@ -27,7 +27,7 @@ class UserCreateForm(Form):
class UserEditForm(Form): class UserEditForm(Form):
quota = fields.IntegerField('Quota') quota_bytes = fields.IntegerField('Quota')
submit = fields.SubmitField('Create') submit = fields.SubmitField('Create')

@ -64,7 +64,7 @@ class User(Address):
# Filters # Filters
forward = db.Column(db.String(160), nullable=True, default=None) forward = db.Column(db.String(160), nullable=True, default=None)
reply_topic = db.Column(db.String(255), nullable=True, default=None) reply_subject = db.Column(db.String(255), nullable=True, default=None)
reply_body = db.Column(db.Text(), nullable=True, default=None) reply_body = db.Column(db.Text(), nullable=True, default=None)
# Settings # Settings

@ -27,7 +27,7 @@ User list
<a href="{{ url_for('user_settings', user_email=user.get_id()) }}" title="Settings"><i class="fa fa-wrench"></i></a>&nbsp; <a href="{{ url_for('user_settings', user_email=user.get_id()) }}" title="Settings"><i class="fa fa-wrench"></i></a>&nbsp;
<a href="{{ url_for('user_password', user_email=user.get_id()) }}" title="Update password"><i class="fa fa-lock"></i></a>&nbsp; <a href="{{ url_for('user_password', user_email=user.get_id()) }}" title="Update password"><i class="fa fa-lock"></i></a>&nbsp;
<a href="{{ url_for('user_forward', user_email=user.get_id()) }}" title="Auto-forward"><i class="fa fa-share"></i></a>&nbsp; <a href="{{ url_for('user_forward', user_email=user.get_id()) }}" title="Auto-forward"><i class="fa fa-share"></i></a>&nbsp;
<a href="{{ url_for('user_vacation', user_email=user.get_id()) }}" title="Vacation"><i class="fa fa-plane"></i></a>&nbsp; <a href="{{ url_for('user_reply', user_email=user.get_id()) }}" title="Auto-reply"><i class="fa fa-plane"></i></a>&nbsp;
<a href="{{ url_for('user_fetchmail', user_email=user.get_id()) }}" title="Fetched accounts"><i class="fa fa-download"></i></a>&nbsp; <a href="{{ url_for('user_fetchmail', user_email=user.get_id()) }}" title="Fetched accounts"><i class="fa fa-download"></i></a>&nbsp;
<a href="{{ url_for('user_edit', user_email=user.get_id()) }}" title="Edit"><i class="fa fa-pencil"></i></a>&nbsp; <a href="{{ url_for('user_edit', user_email=user.get_id()) }}" title="Edit"><i class="fa fa-pencil"></i></a>&nbsp;
<a href="{{ url_for('user_delete', user_email=user.get_id()) }}" title="Delete"><i class="fa fa-trash"></i></a> <a href="{{ url_for('user_delete', user_email=user.get_id()) }}" title="Delete"><i class="fa fa-trash"></i></a>

@ -41,9 +41,9 @@ def user_create(domain_name):
@flask_login.login_required @flask_login.login_required
def user_edit(user_email): def user_edit(user_email):
user = utils.get_user(user_email, True) user = utils.get_user(user_email, True)
form = forms.UserEditForm() form = forms.UserEditForm(obj=user)
if form.validate_on_submit(): if form.validate_on_submit():
user.quota_bytes = form.quota.data user.quota_bytes = form.quota_bytes.data
db.session.add(user) db.session.add(user)
db.session.commit() db.session.commit()
flask.flash('User %s updated' % user) flask.flash('User %s updated' % user)
@ -67,7 +67,7 @@ def user_delete(user_email):
@flask_login.login_required @flask_login.login_required
def user_settings(user_email): def user_settings(user_email):
user = utils.get_user(user_email) user = utils.get_user(user_email)
form = forms.UserSettingsForm() form = forms.UserSettingsForm(obj=user)
if form.validate_on_submit(): if form.validate_on_submit():
user.displayed_name = form.displayed_name.data user.displayed_name = form.displayed_name.data
user.spam_enabled = form.spam_enabled.data user.spam_enabled = form.spam_enabled.data
@ -106,7 +106,7 @@ def user_password(user_email):
@flask_login.login_required @flask_login.login_required
def user_forward(user_email): def user_forward(user_email):
user = utils.get_user(user_email) user = utils.get_user(user_email)
form = forms.UserForwardForm() form = forms.UserForwardForm(obj=user)
if form.validate_on_submit(): if form.validate_on_submit():
user.forward = form.forward.data user.forward = form.forward.data
db.session.add(user) db.session.add(user)
@ -123,7 +123,7 @@ def user_forward(user_email):
@flask_login.login_required @flask_login.login_required
def user_reply(user_email): def user_reply(user_email):
user = utils.get_user(user_email) user = utils.get_user(user_email)
form = forms.UserReplyForm() form = forms.UserReplyForm(obj=user)
if form.validate_on_submit(): if form.validate_on_submit():
user.reply_subject = form.reply_subject.data user.reply_subject = form.reply_subject.data
user.reply_body = form.reply_body.data user.reply_body = form.reply_body.data

Loading…
Cancel
Save