Merge branch 'master' of gits-15.sys.kth.se:ELAB/ELAB-partsearch

master
assar 8 years ago
commit f5b1b67fc7

@ -62,6 +62,7 @@ def getfile(filename):
@app.route('/parts/alter/<partID>', methods=['POST'])
def alter(partID):
partID = int(partID)
s = ''
if partID < 0:
# New entry
@ -74,6 +75,15 @@ def alter(partID):
datasheet_file.save('/srv/datasheets/' + filename)
else:
datasheet_filename = ''
r = db_engine.execute(s, block=request.form['block'],
type=request.form['type'],
partno=request.form['partno'],
partnoalt=request.form['partnoalt'],
partnoalt2=request.form['partnoalt2'],
description=request.form['description'],
quantity=request.form['quantity'],
datasheet=datasheet_filename,
notes=request.form['notes'])
else:
# Modify entry
r = db_engine.execute(text('select * from parts where id=:id;'), id=partID)
@ -92,7 +102,6 @@ def alter(partID):
datasheet_filename = l[0]['datasheet']
s += 'where id=:id;'
s = text(s)
r = db_engine.execute(s, block=request.form['block'],
type=request.form['type'],
partno=request.form['partno'],
@ -101,7 +110,10 @@ def alter(partID):
description=request.form['description'],
quantity=request.form['quantity'],
datasheet=datasheet_filename,
notes=request.form['notes'])
notes=request.form['notes'],
id=partID)
return '{"status":"ok"}'
def connect(user, password, db, host='localhost', port=5432):

Loading…
Cancel
Save