saving participant entries, wip
This commit is contained in:
parent
794cd8efaf
commit
dbf2ec3c5d
@ -79,6 +79,11 @@ def PostShipcalls(schemaModel):
|
|||||||
commands.execute(query, schemaModel)
|
commands.execute(query, schemaModel)
|
||||||
new_id = commands.execute_scalar("select last_insert_id()")
|
new_id = commands.execute_scalar("select last_insert_id()")
|
||||||
|
|
||||||
|
# add participant assignments
|
||||||
|
pquery = "INSERT INTO shipcall_participant_map (shipcall_id, participant_id) VALUES (?shipcall_id?, ?participant_id?)"
|
||||||
|
for participant_id in schemaModel["participants"]:
|
||||||
|
commands.execute(pquery, param={"shipcall_id" : new_id, "participant_id" : participant_id})
|
||||||
|
|
||||||
pooledConnection.close()
|
pooledConnection.close()
|
||||||
|
|
||||||
return json.dumps({"id" : new_id}), 201, {'Content-Type': 'application/json; charset=utf-8'}
|
return json.dumps({"id" : new_id}), 201, {'Content-Type': 'application/json; charset=utf-8'}
|
||||||
@ -116,9 +121,16 @@ def PutShipcalls(schemaModel):
|
|||||||
query += key + " = ?" + key + "? "
|
query += key + " = ?" + key + "? "
|
||||||
|
|
||||||
query += "WHERE id = ?id?"
|
query += "WHERE id = ?id?"
|
||||||
|
|
||||||
affected_rows = commands.execute(query, param=schemaModel)
|
affected_rows = commands.execute(query, param=schemaModel)
|
||||||
|
|
||||||
|
pquery = "SELECT id, participant_id FROM shipcall_participant_map where shipcall_id = ?id?"
|
||||||
|
pdata = commands.query(pquery,param={"id" : schemaModel.id})
|
||||||
|
|
||||||
|
# loop across passed participant ids, creating entries for those not present in pdata
|
||||||
|
|
||||||
|
# loop across existing pdata entries, deleting those not present in participant list
|
||||||
|
|
||||||
|
|
||||||
pooledConnection.close()
|
pooledConnection.close()
|
||||||
|
|
||||||
if affected_rows == 1:
|
if affected_rows == 1:
|
||||||
|
|||||||
@ -79,6 +79,7 @@ class ShipcallSchema(Schema):
|
|||||||
tidal_window_to = fields.DateTime()
|
tidal_window_to = fields.DateTime()
|
||||||
rain_sensitive_cargo = fields.Bool()
|
rain_sensitive_cargo = fields.Bool()
|
||||||
recommended_tugs = fields.Int()
|
recommended_tugs = fields.Int()
|
||||||
|
participants = fields.List(fields.Int)
|
||||||
created = fields.DateTime()
|
created = fields.DateTime()
|
||||||
modified = fields.DateTime()
|
modified = fields.DateTime()
|
||||||
|
|
||||||
|
|||||||
@ -6,4 +6,8 @@ MarkupSafe==1.1.1
|
|||||||
marshmallow==3.9.1
|
marshmallow==3.9.1
|
||||||
webargs==6.1.1
|
webargs==6.1.1
|
||||||
Werkzeug==1.0.1
|
Werkzeug==1.0.1
|
||||||
pydapper[mysql-connector-python]
|
pydapper[mysql-connector-python]
|
||||||
|
marshmallow-dataclass
|
||||||
|
bcrypt
|
||||||
|
jwt
|
||||||
|
flask-jwt-extended
|
||||||
Reference in New Issue
Block a user