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.
This commit is contained in:
parent
98d713234b
commit
7365949fb5
@ -288,8 +288,10 @@ def PutShipcalls(schemaModel, original_payload=None):
|
|||||||
dquery = "DELETE FROM shipcall_participant_map WHERE id = ?existing_id?"
|
dquery = "DELETE FROM shipcall_participant_map WHERE id = ?existing_id?"
|
||||||
commands.execute(dquery, param={"existing_id" : elem["id"]})
|
commands.execute(dquery, param={"existing_id" : elem["id"]})
|
||||||
# TODO: Create un-assignment notification but only if level > 0 else delete existing notification
|
# TODO: Create un-assignment notification but only if level > 0 else delete existing notification
|
||||||
|
found_assignment_notification = False
|
||||||
for existing_notification in existing_notifications:
|
for existing_notification in existing_notifications:
|
||||||
if existing_notification["participant_id"] == elem["participant_id"]:
|
if existing_notification["participant_id"] == elem["participant_id"]:
|
||||||
|
found_assignment_notification = True
|
||||||
if existing_notification["level"] == 0:
|
if existing_notification["level"] == 0:
|
||||||
nquery = "DELETE FROM notification WHERE id = ?nid?"
|
nquery = "DELETE FROM notification WHERE id = ?nid?"
|
||||||
commands.execute(nquery, param={"nid" : existing_notification["id"]})
|
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?)"
|
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})
|
commands.execute(nquery, param={"shipcall_id" : schemaModel["id"], "participant_id" : elem["participant_id"], "message" : message})
|
||||||
break
|
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")
|
canceled_value = schemaModel.get("canceled")
|
||||||
if canceled_value is not None:
|
if canceled_value is not None:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user