Skip to content

Commit

Permalink
add exception handling in case state doesn't change
Browse files Browse the repository at this point in the history
  • Loading branch information
John Tordoff authored and Uditi Mehta committed Aug 9, 2024
1 parent af412d8 commit 188bc15
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion admin/preprints/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ def post(self, request, *args, **kwargs):
new_machine_state = request.POST.get('machine_state')
if new_machine_state and preprint.machine_state != new_machine_state:
preprint.machine_state = new_machine_state
preprint.save()
try:
preprint.save()
except Exception as e:
messages.error(self.request, e.message)

preprint.refresh_from_db()

return redirect(self.get_success_url())
Expand Down

0 comments on commit 188bc15

Please sign in to comment.