diff --git a/src/server/BreCal/impl/shipcalls.py b/src/server/BreCal/impl/shipcalls.py index 766ac1b..8e99e6b 100644 --- a/src/server/BreCal/impl/shipcalls.py +++ b/src/server/BreCal/impl/shipcalls.py @@ -288,8 +288,10 @@ def PutShipcalls(schemaModel, original_payload=None): dquery = "DELETE FROM shipcall_participant_map WHERE id = ?existing_id?" commands.execute(dquery, param={"existing_id" : elem["id"]}) # TODO: Create un-assignment notification but only if level > 0 else delete existing notification + found_assignment_notification = False for existing_notification in existing_notifications: if existing_notification["participant_id"] == elem["participant_id"]: + found_assignment_notification = True if existing_notification["level"] == 0: nquery = "DELETE FROM notification WHERE id = ?nid?" commands.execute(nquery, param={"nid" : existing_notification["id"]}) @@ -299,6 +301,10 @@ def PutShipcalls(schemaModel, original_payload=None): nquery = "INSERT INTO notification (shipcall_id, participant_id, level, type, message) VALUES (?shipcall_id?, ?participant_id?, 0, 5, ?message?)" commands.execute(nquery, param={"shipcall_id" : schemaModel["id"], "participant_id" : elem["participant_id"], "message" : message}) break + if not found_assignment_notification: + message = "The participant has been unassigned from the shipcall." + nquery = "INSERT INTO notification (shipcall_id, participant_id, level, type, message) VALUES (?shipcall_id?, ?participant_id?, 0, 5, ?message?)" + commands.execute(nquery, param={"shipcall_id" : schemaModel["id"], "participant_id" : elem["participant_id"], "message" : message}) canceled_value = schemaModel.get("canceled") if canceled_value is not None: