Hopefully fixed id problem

master
Davide Bongiovanni 8 years ago
parent d8585207a4
commit 00608b18ef

@ -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['datasheet'] datasheet_filename = l['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