From 7365949fb52f990e7b2fc8d516f4a8ae58fe074b Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Thu, 22 Jan 2026 07:47:09 +0100 Subject: [PATCH] Create an un-assignment notification for a participant when he is no longer assigned, even if there was no previous assignment notification. That can happen I believe if the assigment was maybe too long ago and the notification therefore already deleted. Note that this needs to be tested and may be rolled back if this doesn't solve the issue. --- src/server/BreCal/impl/shipcalls.py | 6 ++++++ 1 file changed, 6 insertions(+) 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: