diff --git a/progit/ui/repo.py b/progit/ui/repo.py index 9372a83..56f8ef3 100644 --- a/progit/ui/repo.py +++ b/progit/ui/repo.py @@ -739,11 +739,15 @@ def remove_user(repo, userid, username=None): if str(user.user.id) == str(userid): SESSION.delete(user) break - SESSION.commit() - - progit.generate_gitolite_acls() + try: + SESSION.commit() + progit.generate_gitolite_acls() + flask.flash('User removed') + except SQLAlchemyError as err: + SESSION.rollback() + APP.logger.exception(err) + flask.flash('User could not be removed', 'error') - flask.flash('User removed') return flask.redirect( flask.url_for('.view_settings', repo=repo.name, username=username) ) @@ -779,7 +783,12 @@ def add_user(repo, username=None): '.view_settings', repo=repo.name, username=username) ) except progit.exceptions.ProgitException as msg: + SESSION.rollback() flask.flash(msg, 'error') + except SQLAlchemyError as err: + SESSION.rollback() + APP.logger.exception(err) + flask.flash('User could not be added', 'error') return flask.render_template( 'add_user.html',