From 2c31c685ac1d65429c3bdbcf6fcbaf56b6a8e647 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Gru=CC=88ndger?= Date: Fri, 22 May 2020 00:41:35 +0200 Subject: [PATCH] Fixed routes (name/receiver_name instead of id) --- app/main/routes.py | 10 +++++----- app/templates/devices.html | 4 ++-- app/templates/receivers.html | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/main/routes.py b/app/main/routes.py index 33d17db..42f7925 100644 --- a/app/main/routes.py +++ b/app/main/routes.py @@ -57,8 +57,8 @@ def devices(): @bp.route("/device_detail.html", methods=["GET", "POST"]) def device_detail(): - device_id = request.args.get("id") - device = db.session.query(Device).filter(Device.id == device_id).one() + device_name = request.args.get("device_name") + device = db.session.query(Device).filter(Device.name == device_name).one() return render_template("device_detail.html", title="Device", device=device) @@ -80,15 +80,15 @@ def receivers(): @bp.route("/receiver_detail.html") def receiver_detail(): - sel_receiver_id = request.args.get("receiver_id") + receiver_name = request.args.get("receiver_name") - receiver = db.session.query(Receiver).filter(Receiver.id == sel_receiver_id).one() + receiver = db.session.query(Receiver).filter(Receiver.name == receiver_name).one() airport = ( db.session.query(Airport) .filter( db.and_( - Receiver.id == sel_receiver_id, + Receiver.name == receiver_name, db.func.st_contains(db.func.st_buffer(Receiver.location_wkt, 0.5), Airport.location_wkt), db.func.st_distance_sphere(Airport.location_wkt, Receiver.location_wkt) < 1000, ) diff --git a/app/templates/devices.html b/app/templates/devices.html index 0e9fabe..f0a71e1 100644 --- a/app/templates/devices.html +++ b/app/templates/devices.html @@ -8,14 +8,14 @@
- + {% for device in devices %} - + diff --git a/app/templates/receivers.html b/app/templates/receivers.html index 5b74d4c..098248c 100644 --- a/app/templates/receivers.html +++ b/app/templates/receivers.html @@ -28,7 +28,7 @@ {% for receiver in receivers %} - + {% endfor %}
AddressName Registration Software version
{{ device.address }}{{ device.name }} {% if device.info is not none %}{{ device.info.registration }}{% else %} - {% endif %} {% if device.software_version is not none %}{{ device.software_version }}{% else %} - {% endif %}
{{ receiver.country.iso2 }} {{ receiver.name }}{{ receiver.country.iso2 }} {{ receiver.name }} {{ receiver.altitude|int }} m