From 37132489e224d872aceaa9b09de6d6d22ce9a270 Mon Sep 17 00:00:00 2001 From: Lorenzo Balugani Date: Tue, 25 May 2021 17:01:36 +0200 Subject: [PATCH] Fix bug that prevented alert to be deleted --- nest_backend/routes/repository/alerts/alert.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/nest_backend/routes/repository/alerts/alert.py b/nest_backend/routes/repository/alerts/alert.py index c40b1db..35eaccf 100644 --- a/nest_backend/routes/repository/alerts/alert.py +++ b/nest_backend/routes/repository/alerts/alert.py @@ -175,9 +175,16 @@ def page_alert(aid): return json_success(alert.to_json()), 200 elif request.method == "DELETE": 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.commit() - except Exception: + except Exception as e: return json_error("Something went wrong while deleting alert.", ALERT_DELETION_FAILURE), 500 return json_success("Deletion completed."), 204 elif request.method == "PUT":