Fixed routes (name/receiver_name instead of id)

pull/78/head
Konstantin Gründger 2020-05-22 00:41:35 +02:00
rodzic c4ec856f26
commit 2c31c685ac
3 zmienionych plików z 8 dodań i 8 usunięć

Wyświetl plik

@ -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,
)

Wyświetl plik

@ -8,14 +8,14 @@
<div class="panel-body">
<table class="datatable table table-striped table-bordered">
<tr>
<th>Address</th>
<th>Name</th>
<th>Registration</th>
<th>Software version</th>
</tr>
{% for device in devices %}
<tr>
<td><a href="{{ url_for('main.device_detail', id=device.id) }}">{{ device.address }}</a></td>
<td><a href="{{ url_for('main.device_detail', device_name=device.name) }}">{{ device.name }}</a></td>
<td>{% if device.info is not none %}{{ device.info.registration }}{% else %} - {% endif %}</td>
<td {% if device.software_version and device.software_version < 6.6 %}class="danger"{% endif %}>{% if device.software_version is not none %}{{ device.software_version }}{% else %} - {% endif %}</td>
</tr>

Wyświetl plik

@ -28,7 +28,7 @@
{% for receiver in receivers %}
<tr>
<td><img src="{{ url_for('static', filename='img/Transparent.gif') }}" class="flag flag-{{ receiver.country.iso2|lower }}" alt="{{ receiver.country.iso2 }}"/> <a href="{{ url_for('main.receiver_detail', receiver_id=receiver.id) }}">{{ receiver.name }}</a></td>
<td><img src="{{ url_for('static', filename='img/Transparent.gif') }}" class="flag flag-{{ receiver.country.iso2|lower }}" alt="{{ receiver.country.iso2 }}"/> <a href="{{ url_for('main.receiver_detail', receiver_name=receiver.name) }}">{{ receiver.name }}</a></td>
<td>{{ receiver.altitude|int }} m</td>
</tr>
{% endfor %}