From 4988f0eebd13b892f0570acdb9e2d74f8493c6c0 Mon Sep 17 00:00:00 2001 From: Marek Baczynski Date: Tue, 29 Nov 2022 00:15:26 +0100 Subject: [PATCH] fixed path added javascript --- parts/server.py | 4 +++- parts/static/script.js | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/parts/server.py b/parts/server.py index 1eea45b..1bc0d02 100755 --- a/parts/server.py +++ b/parts/server.py @@ -316,8 +316,10 @@ def alter(partID): r.close() return '{"status":"ok", "part_id" : ' + str(new_id) + '}' -@app.route(baseURL+'/parts/report_missing/', methods=['POST']) +@app.route(baseURL+'/report_missing', methods=['POST']) def report_missing(): + if 'partID' not in request.form: + return '{"status":"fail"}' partID = request.form['partID'] missing = True if request.form['missing']=='missing' else False #must be "missing" or "found" if missing: diff --git a/parts/static/script.js b/parts/static/script.js index b32f549..ee7e4e6 100755 --- a/parts/static/script.js +++ b/parts/static/script.js @@ -145,6 +145,31 @@ function save(partID) { perform_query(); } +function report_missing(partID, missing){ + var data = new FormData(); + data.append('partID', partID); + if(missing){ + data.append('missing', 'missing') + }else{ + data.append('missing', 'found') + } + $.ajax({ + url: rootURL + 'report_missing', + type: 'POST', + data: data, + cache: false, + contentType: false, + processData: false, + success: function(data) { + alert("Thank you for reporting part as " + missing "."); + }, + error: function() { + alert("Couldn't update the part information. Please retry."); + } + + }); +} + function text_filter(string) { if (string != null) return string;