From b44d05aabd27d748750dd0cbb7ca5a891683431f Mon Sep 17 00:00:00 2001 From: Davide Bongiovanni Date: Tue, 13 Nov 2018 22:07:02 +0100 Subject: [PATCH 1/2] Resetting url input on new part if datasheet is empty --- parts/static/script.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/parts/static/script.js b/parts/static/script.js index 0195bc0..d59268c 100644 --- a/parts/static/script.js +++ b/parts/static/script.js @@ -182,8 +182,10 @@ function show_part_info(partID) { $('tr#datasheet-head').html($('DATASHEET: ')); $('input[name=datasheet-url-input]').val(data.datasheet); } - else + else { $('tr#datasheet-head td').text('DATASHEET: '); + $('input[name=datasheet-url-input]').val(''); + } $('#edit-button').click(function() { init_edit(partID); }); From cc6a1473cbfb9c12a3972022ed32e6ac83c2c8eb Mon Sep 17 00:00:00 2001 From: Davide Bongiovanni Date: Tue, 13 Nov 2018 22:07:19 +0100 Subject: [PATCH 2/2] Correctly deleting existing datasheet --- parts/server.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/parts/server.py b/parts/server.py index dfdafa7..5b7d277 100644 --- a/parts/server.py +++ b/parts/server.py @@ -254,9 +254,9 @@ def alter(partID): datasheet_file.save('/srv/datasheets/' + datasheet_filename) 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'] + whole_url = l[0]['datasheet'] + actual_filename = whole_url[whole_url.rfind('/') + 1:] + os.remove('/srv/datasheets/' + actual_filename) else: try: datasheet_filename = request.form['datasheet-url']