Skip to content

Commit

Permalink
Make UI show a useful message when deleting fails
Browse files Browse the repository at this point in the history
  • Loading branch information
anishathalye committed Jan 4, 2020
1 parent e3c2fb0 commit 7984f10
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions gavel/controllers/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ def tx():
db.session.commit()
with_retries(tx)
except IntegrityError as e:
return utils.server_error(str(e))
if isinstance(e.orig, psycopg2.errors.ForeignKeyViolation):
return utils.server_error("Projects can't be deleted once they have been voted on by a judge. You can use the 'disable' functionality instead, which has a similar effect, preventing the project from being shown to judges.")
else:
return utils.server_error(str(e))
return redirect(url_for('admin'))


Expand Down Expand Up @@ -178,7 +181,10 @@ def tx():
db.session.commit()
with_retries(tx)
except IntegrityError as e:
return utils.server_error(str(e))
if isinstance(e.orig, psycopg2.errors.ForeignKeyViolation):
return utils.server_error("Judges can't be deleted once they have voted on a project. You can use the 'disable' functionality instead, which has a similar effect, locking out the judge and preventing them from voting on any other projects.")
else:
return utils.server_error(str(e))
return redirect(url_for('admin'))

@app.route('/admin/setting', methods=['POST'])
Expand Down

0 comments on commit 7984f10

Please sign in to comment.