Fixed datsheet info upload check. NOW WITH TRY-CATCH!

pull/3/head
Davide Bongiovanni 6 years ago
parent 08b8646374
commit 7098d19225

@ -89,7 +89,7 @@ def locationEditor():
return render_template('locationEditor.html', locations=locations, containers=getContainers())
@app.route('/parts/alterLocation/<locationID>', methods=['POST'])
# @requires_auth
@requires_auth
def alterLocation(locationID):
locationID = int(locationID)
s = ''
@ -193,7 +193,7 @@ def getfile(filename):
return send_from_directory('/srv/datasheets/', filename + '.pdf')
@app.route('/parts/alter/<partID>', methods=['POST'])
# @requires_auth
@requires_auth
def alter(partID):
partID = int(partID)
s = ''
@ -212,9 +212,13 @@ def alter(partID):
i += 1
datasheet_file.save('/srv/datasheets/' + datasheet_filename)
datasheet_filename = 'http://elab.kth.se/parts/getfile/' + datasheet_filename
elif request.form.has_key('datasheet-url'):
datasheet_filename = request.form['datasheet-url']
# elif request.form.has_key('datasheet-url'):
# datasheet_filename = request.form['datasheet-url']
else:
try:
datasheet_filename = request.form['datasheet-url']
except:
print('No docs provided')
datasheet_filename = None
r = db_engine.execute(s, partno=request.form['partno'],
description=request.form['description'],
@ -240,9 +244,13 @@ def alter(partID):
datasheet_filename = 'http://elab.kth.se/parts/getfile/' + datasheet_filename
if l[0]['datasheet'] != None:
os.remove('/srv/datasheets/' + l[0]['datasheet'])
elif request.form.has_key('datasheet-url'):
datasheet_filename = request.form['datasheet-url']
# elif request.form.has_key('datasheet-url'):
# datasheet_filename = request.form['datasheet-url']
else:
try:
datasheet_filename = request.form['datasheet-url']
except:
print('No docs provided')
datasheet_filename = l[0]['datasheet']
s += 'where id=:id returning id;'
s = text(s)

Loading…
Cancel
Save