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

pull/3/head
assar 8 years ago
commit f5b1b67fc7

@ -62,6 +62,7 @@ def getfile(filename):
@app.route('/parts/alter/<partID>', methods=['POST']) @app.route('/parts/alter/<partID>', methods=['POST'])
def alter(partID): def alter(partID):
partID = int(partID)
s = '' s = ''
if partID < 0: if partID < 0:
# New entry # New entry
@ -74,6 +75,15 @@ def alter(partID):
datasheet_file.save('/srv/datasheets/' + filename) datasheet_file.save('/srv/datasheets/' + filename)
else: else:
datasheet_filename = '' 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: else:
# Modify entry # Modify entry
r = db_engine.execute(text('select * from parts where id=:id;'), id=partID) r = db_engine.execute(text('select * from parts where id=:id;'), id=partID)
@ -92,16 +102,18 @@ def alter(partID):
datasheet_filename = l[0]['datasheet'] datasheet_filename = l[0]['datasheet']
s += 'where id=:id;' s += 'where id=:id;'
s = text(s) s = text(s)
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'],
id=partID)
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'])
return '{"status":"ok"}' return '{"status":"ok"}'
def connect(user, password, db, host='localhost', port=5432): def connect(user, password, db, host='localhost', port=5432):

Loading…
Cancel
Save