Hopefully fixed id problem

pull/3/head
Davide Bongiovanni 8 years ago
parent d8585207a4
commit 00608b18ef

@ -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,16 +102,18 @@ def alter(partID):
datasheet_filename = l['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'],
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"}'
def connect(user, password, db, host='localhost', port=5432):

Loading…
Cancel
Save