added backed of missing part reporting

missing-part-reporting
Marek Baczynski 2 years ago
parent b698ec446f
commit aca7505ae9

@ -164,7 +164,7 @@ def alterUser(userID):
@app.route(baseURL+'/getpartinfo/<partID>')
def get_part_info(partID):
s = 'select p.id,partno,description,notes, c.name || l.name as location_descriptor, location_id, container_id, datasheet from parts as p inner join locations as l on p.location_id = l.id inner join containers as c on l.container_id = c.id where p.id = :id;'
s = 'select p.id,partno,description,notes, c.name || l.name as location_descriptor, location_id, container_id, datasheet, EXTRACT(EPOCH from now()-reported_missing) as missing_for from parts as p inner join locations as l on p.location_id = l.id inner join containers as c on l.container_id = c.id where p.id = :id;'
r = db_engine.execute(text(s), id=partID)
l = []
for row in r:
@ -316,6 +316,19 @@ def alter(partID):
r.close()
return '{"status":"ok", "part_id" : ' + str(new_id) + '}'
@app.route(baseURL+'/parts/report_missing/', methods=['POST'])
def report_missing():
partID = request.form['partID']
missing = True if request.form['missing']=='missing' else False #must be "missing" or "found"
if missing:
r = db_engine.execute(text('update parts set reported_missing = now() where id=:id;'), id=partID)
r.close()
return '{"status":"ok"}'
else:
r = db_engine.execute(text('update parts set reported_missing = NULL where id=:id;'), id=partID)
r.close()
return '{"status":"ok"}'
@app.route(baseURL+'/delete/<partID>')
@requires_auth
def delete(partID):

Loading…
Cancel
Save