From 3788060c7888942e3c4e6a0226cab0568d6e8350 Mon Sep 17 00:00:00 2001 From: Davide Bongiovanni Date: Sun, 11 Nov 2018 20:27:43 +0100 Subject: [PATCH] Fetching containers instead of locations. Fixed query and relative script for get_part_info --- parts/server.py | 10 +++++----- parts/static/script.js | 4 ++-- parts/templates/partsearch.html | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/parts/server.py b/parts/server.py index f62fcc0..edcb33d 100644 --- a/parts/server.py +++ b/parts/server.py @@ -47,13 +47,13 @@ def serveImage(img): @app.route('/parts') def index(): - query = "select id, name from locations order by UPPER(name);" + query = "select id, name from containers order by UPPER(name);" r = db_engine.execute(text(query)) - locations = [] + containers = [] for row in r: - locations.append(dict(row)) + containers.append(dict(row)) r.close() - return render_template('partsearch.html', locations=locations) + return render_template('partsearch.html', containers=containers) @app.route('/parts/getlocationsInContainer/') def get_locations_in_container(containerID): @@ -112,7 +112,7 @@ def alterLocation(locationID): @app.route('/parts/getpartinfo/') def get_part_info(partID): - s = 'select * from parts as p inner join locations as l on p.location_id=l.id where p.id = :id;' + s = 'select p.id,partno,description, c.name || l.name as location_descriptor, location_id, container_id datasheet from parts as p inner join locations as l on p.location_id = l.id inner join containers as c on l.container_id = c.id where p.id = :id;' r = db_engine.execute(text(s), id=partID) l = [] for row in r: diff --git a/parts/static/script.js b/parts/static/script.js index af31969..73c23a9 100644 --- a/parts/static/script.js +++ b/parts/static/script.js @@ -131,13 +131,13 @@ function delete_entry(partID) { function show_part_info(partID) { $.getJSON(rootURL + 'getpartinfo/' + partID, function(data) { - $('table#details tr#location td p').text(text_filter(data.name)); // name is the location friendly name + $('table#details tr#location td p').text(text_filter(data.location_descriptor)); // name is the location friendly name $('table#details tr#location td select').val(data.location_id); // name is the location friendly name $('table#details tr#partno td p').text(text_filter(data.partno)); $('table#details tr#partno td input').val(text_filter(data.partno)); $('table#details tr#description td p').text(text_filter(data.description)); $('table#details tr#description td input').val(text_filter(data.description)); - $('img#map').attr('src', 'parts/map/' + data.map); + $('img#map').attr('src', 'parts/map/' + data.container_id); if (data.datasheet != null) $('tr#datasheet-head').html($('DATASHEET: ')); else diff --git a/parts/templates/partsearch.html b/parts/templates/partsearch.html index e589255..bd531ad 100644 --- a/parts/templates/partsearch.html +++ b/parts/templates/partsearch.html @@ -45,8 +45,8 @@ LOCATION