1
0
mirror of https://github.com/Mailu/Mailu.git synced 2024-12-14 10:53:30 +02:00

Do not always add objects to the session before committing

This commit is contained in:
Pierre Jaury 2016-05-06 23:27:11 +02:00
parent 2396324e21
commit 82ec86afd8
6 changed files with 0 additions and 12 deletions

View File

@ -22,7 +22,6 @@ def admin_create():
user = models.User.query.get(form.admin.data)
if user:
user.global_admin = True
db.session.add(user)
db.session.commit()
flask.flash('User %s is now admin' % user)
return flask.redirect(flask.url_for('.admin_list'))
@ -37,7 +36,6 @@ def admin_delete(admin):
user = models.User.query.get(admin)
if user:
user.global_admin = False
db.session.add(user)
db.session.commit()
flask.flash('User %s is no longer admin' % user)
return flask.redirect(flask.url_for('.admin_list'))

View File

@ -45,7 +45,6 @@ def alias_edit(alias):
wtforms_components.read_only(form.localpart)
if form.validate_on_submit():
form.populate_obj(alias)
db.session.add(alias)
db.session.commit()
flask.flash('Alias %s updated' % alias)
return flask.redirect(

View File

@ -39,7 +39,6 @@ def domain_edit(domain_name):
wtforms_components.read_only(form.name)
if form.validate_on_submit():
form.populate_obj(domain)
db.session.add(domain)
db.session.commit()
flask.flash('Domain %s saved' % domain)
return flask.redirect(flask.url_for('.domain_list'))

View File

@ -38,7 +38,6 @@ def fetch_edit(fetch_id):
form = forms.FetchForm(obj=fetch)
if form.validate_on_submit():
form.populate_obj(fetch)
db.session.add(fetch)
db.session.commit()
flask.flash('Fetch configuration updated')
return flask.redirect(

View File

@ -24,7 +24,6 @@ def manager_create(domain_name):
flask.flash('User %s is already manager' % user, 'error')
else:
domain.managers.append(user)
db.session.add(domain)
db.session.commit()
flask.flash('User %s can now manage %s' % (user, domain.name))
return flask.redirect(
@ -40,7 +39,6 @@ def manager_delete(manager):
domain = utils.get_domain_admin(user.domain_name)
if user in domain.managers:
domain.managers.remove(user)
db.session.add(domain)
db.session.commit()
flask.flash('User %s can no longer manager %s' % (user, domain))
else:

View File

@ -49,7 +49,6 @@ def user_edit(user_email):
form.populate_obj(user)
if form.pw.data:
user.set_password(form.pw.data)
db.session.add(user)
db.session.commit()
flask.flash('User %s updated' % user)
return flask.redirect(
@ -76,7 +75,6 @@ def user_settings(user_email):
form = forms.UserSettingsForm(obj=user)
if form.validate_on_submit():
form.populate_obj(user)
db.session.add(user)
db.session.commit()
flask.flash('Settings updated for %s' % user)
if user_email:
@ -96,7 +94,6 @@ def user_password(user_email):
flask.flash('Passwords do not match', 'error')
else:
user.set_password(form.pw.data)
db.session.add(user)
db.session.commit()
flask.flash('Password updated for %s' % user)
if user_email:
@ -116,7 +113,6 @@ def user_forward(user_email):
user.forward = form.forward.data
else:
user.forward = None
db.session.add(user)
db.session.commit()
flask.flash('Forward destination updated for %s' % user)
if user_email:
@ -133,7 +129,6 @@ def user_reply(user_email):
form = forms.UserReplyForm(obj=user)
if form.validate_on_submit():
form.populate_obj(user)
db.session.add(user)
db.session.commit()
flask.flash('Auto-reply message updated for %s' % user)
if user_email: