creating notifications if a shipcall is cancelled
This commit is contained in:
parent
91caf74dca
commit
cda3f231a7
@ -207,6 +207,8 @@ def PutShipcalls(schemaModel):
|
|||||||
if theshipcall is sentinel:
|
if theshipcall is sentinel:
|
||||||
pooledConnection.close()
|
pooledConnection.close()
|
||||||
return json.dumps("no such record"), 404, {'Content-Type': 'application/json; charset=utf-8'}
|
return json.dumps("no such record"), 404, {'Content-Type': 'application/json; charset=utf-8'}
|
||||||
|
|
||||||
|
was_canceled = theshipcall["canceled"]
|
||||||
|
|
||||||
# query = SQLQuery.get_shipcall_put(schemaModel)
|
# query = SQLQuery.get_shipcall_put(schemaModel)
|
||||||
query = "UPDATE shipcall SET "
|
query = "UPDATE shipcall SET "
|
||||||
@ -257,7 +259,7 @@ def PutShipcalls(schemaModel):
|
|||||||
pquery = "SELECT id, participant_id, type FROM shipcall_participant_map where shipcall_id = ?id?"
|
pquery = "SELECT id, participant_id, type FROM shipcall_participant_map where shipcall_id = ?id?"
|
||||||
pdata = commands.query(pquery,param={"id" : schemaModel["id"]}) # existing list of assignments
|
pdata = commands.query(pquery,param={"id" : schemaModel["id"]}) # existing list of assignments
|
||||||
|
|
||||||
# loop across passed participant ids, creating entries for those not present in pdata
|
# loop across passed participant ids, creating entries for those not present in pdata
|
||||||
|
|
||||||
existing_notifications = get_notification_for_shipcall_and_type(schemaModel["id"], 1) # type = 1 is assignment
|
existing_notifications = get_notification_for_shipcall_and_type(schemaModel["id"], 1) # type = 1 is assignment
|
||||||
|
|
||||||
@ -304,7 +306,14 @@ def PutShipcalls(schemaModel):
|
|||||||
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 schemaModel["canceled"] is not None:
|
||||||
|
if schemaModel["canceled"] and not was_canceled:
|
||||||
|
# create a canceled notification for all currently assigned participants
|
||||||
|
stornoNotificationQuery = "INSERT INTO notification (shipcall_id, participant_id, level, type, message) VALUES (?shipcall_id?, ?participant_id?, 0, 7, ?message?)"
|
||||||
|
for participant_assignment in schemaModel["participants"]:
|
||||||
|
commands.execute(stornoNotificationQuery, param={"shipcall_id" : schemaModel["id"], "participant_id" : participant_assignment["participant_id"], "message" : message})
|
||||||
|
|
||||||
# save history data
|
# save history data
|
||||||
# TODO: set ETA properly
|
# TODO: set ETA properly
|
||||||
# query = SQLQuery.create_sql_query_history_put()
|
# query = SQLQuery.create_sql_query_history_put()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user