1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-22 04:54:18 +00:00

Fix bug that prevented alert to be deleted

This commit is contained in:
Lorenzo Balugani 2021-05-25 17:01:36 +02:00
parent 4f274fa9af
commit 37132489e2

View file

@ -175,9 +175,16 @@ def page_alert(aid):
return json_success(alert.to_json()), 200 return json_success(alert.to_json()), 200
elif request.method == "DELETE": elif request.method == "DELETE":
try: try:
for elem in alert.conditions:
condition = elem.condition
ext.session.delete(elem)
ext.session.commit()
if not condition.repository_id:
ext.session.delete(condition)
ext.session.commit()
ext.session.delete(alert) ext.session.delete(alert)
ext.session.commit() ext.session.commit()
except Exception: except Exception as e:
return json_error("Something went wrong while deleting alert.", ALERT_DELETION_FAILURE), 500 return json_error("Something went wrong while deleting alert.", ALERT_DELETION_FAILURE), 500
return json_success("Deletion completed."), 204 return json_success("Deletion completed."), 204
elif request.method == "PUT": elif request.method == "PUT":