diff --git a/ogn_python/model/device.py b/ogn_python/model/device.py
index 16a2413..4b04e37 100644
--- a/ogn_python/model/device.py
+++ b/ogn_python/model/device.py
@@ -3,6 +3,7 @@ from sqlalchemy.ext.hybrid import hybrid_property
from ogn_python import db
from .device_info import DeviceInfo
+
class Device(db.Model):
__tablename__ = 'devices'
diff --git a/ogn_python/routes.py b/ogn_python/routes.py
index cb01971..f4fd8a4 100644
--- a/ogn_python/routes.py
+++ b/ogn_python/routes.py
@@ -65,16 +65,16 @@ def receiver_detail():
.filter(Receiver.id == sel_receiver_id) \
.one()
- near_airports = db.session.query(Airport, func.st_distancesphere(Airport.location_wkt, Receiver.location_wkt).label('distance')) \
- .filter(and_(Receiver.id == sel_receiver_id), func.st_contains(func.st_buffer(Receiver.location_wkt, 0.5), Airport.location_wkt)) \
+ airport = db.session.query(Airport) \
+ .filter(and_(Receiver.id == sel_receiver_id,
+ func.st_contains(func.st_buffer(Receiver.location_wkt, 0.5), Airport.location_wkt),
+ func.st_distance_sphere(Airport.location_wkt, Receiver.location_wkt) < 1000)) \
.filter(Airport.style.in_((2,4,5))) \
- .order_by(func.st_distancesphere(Airport.location_wkt, Receiver.location_wkt)) \
- .limit(10)
return render_template('receiver_detail.html',
title='Receiver Detail',
receiver=receiver,
- near_airports=near_airports)
+ airport=airport.first())
@app.route('/airports.html', methods=['GET', 'POST'])
@@ -92,19 +92,31 @@ def airports():
.group_by(Airport.id) \
.order_by(Airport.name)
else:
- airports = db.session.query(Airport) \
- .filter(or_(Logbook.takeoff_airport_id == Airport.id, Logbook.landing_airport_id == Airport.id)) \
- .group_by(Airport.id) \
- .order_by(Airport.name)
+ airports = []
page = request.args.get('page', 1, type=int)
- return render_template('airports.html', sel_country=sel_country, countries=countries_in_logbook, airports=airports)
+ return render_template('airports.html',
+ sel_country=sel_country,
+ countries=countries_in_logbook,
+ airports=airports)
-@app.route('/airport.html')
-def airport():
- pass
+@app.route('/airport_detail.html')
+def airport_detail():
+ sel_airport = request.args.get('airport')
+
+ airport = db.session.query(Airport) \
+ .filter(Airport.id == sel_airport)
+
+ devices = db.session.query(Device).join(Logbook) \
+ .filter(Logbook.takeoff_airport_id == sel_airport) \
+ .order_by(Device.address)
+
+ return render_template('airport_detail.html',
+ title='Airport Detail',
+ airport=airport.one(),
+ devices=devices)
@app.route('/logbook.html', methods=['GET', 'POST'])
@@ -182,6 +194,7 @@ def logbook():
dates=dates,
logbook=logbook)
+
@app.route('/statistics.html')
def statistics():
receiverstats = db.session.query(ReceiverStats) \
@@ -191,6 +204,7 @@ def statistics():
# Backend routes for other sites
+
@app.route('/live.html')
def live():
return render_template('ogn_live.jinja')
\ No newline at end of file
diff --git a/ogn_python/templates/airport_detail.html b/ogn_python/templates/airport_detail.html
new file mode 100644
index 0000000..7088b42
--- /dev/null
+++ b/ogn_python/templates/airport_detail.html
@@ -0,0 +1,44 @@
+{% extends "base.html" %}
+
+{% block content %}
+
+
+
+
+
Airport Details
+
+ Name: | {{ airport.name }} |
+ Code: | {{ airport.code }} |
+ Altitude: | {{ airport.altitude|int }} m |
+ Style: | {{ airport.style }} |
+ Description: | {{ airport.description }} |
+ Runway Direction: | {{ airport.runway_direction }} |
+ Runway Length: | {{ airport.runway_length }} m |
+ Frequency: | {{ airport.frequency }} MHz |
+
+
+
+
+
Seen Devices
+
+
+ Address |
+ Registration |
+ Last takeoff/landing |
+ Software version |
+
+
+ {% for device in devices %}
+
+ {{ device.address }} |
+ {% if device.info is none %}-{% else %}{{ device.info.registration }}{% endif %} |
+ {% if device.takeoff_landings %}{% set last_action = device.takeoff_landings|last %}{% if last_action.is_takeoff == True %}↗{% else %}↘{% endif %} @ {{ last_action.timestamp.strftime('%Y-%m-%d %H:%M:%S') }}{% endif %}
+ | {{ device.software_version }} |
+
+ {% endfor %}
+
+
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/ogn_python/templates/airports.html b/ogn_python/templates/airports.html
index 6636205..34ac124 100644
--- a/ogn_python/templates/airports.html
+++ b/ogn_python/templates/airports.html
@@ -24,14 +24,14 @@
# |
Name |
- Country |
+ Logbook (takeoff and landings) |
{% for airport in airports %}
{{ loop.index }}
- | {{ airport.name }} |
-  }}) |
+ {{ airport.name }} |
+ Logbook |
{% endfor %}
diff --git a/ogn_python/templates/logbook.html b/ogn_python/templates/logbook.html
index c4e3ea9..de41b40 100644
--- a/ogn_python/templates/logbook.html
+++ b/ogn_python/templates/logbook.html
@@ -51,7 +51,7 @@
{% if entry.takeoff_track is not none and entry.takeoff_airport.id|string() == sel_airport %} {{ '%02d' | format(entry.takeoff_track/10) }} {% endif %} |
{% if entry.landing_timestamp is not none and entry.landing_airport.id|string() == sel_airport %} {{ entry.landing_timestamp.strftime('%H:%M') }} {% endif %} |
{% if entry.landing_track is not none and entry.landing_airport.id|string() == sel_airport %} {{ '%02d' | format(entry.landing_track/10) }} {% endif %} |
- {% if entry.max_altitude is not none %}{{ entry.max_altitude - entry.takeoff_airport.altitude }} m{% endif %} |
+ {% if entry.max_altitude is not none %}{{ '%0.1f'|format(entry.max_altitude - entry.takeoff_airport.altitude) }} m{% endif %} |
{% if entry.takeoff_airport is not none and entry.takeoff_airport.id|string() != sel_airport %}Take Off: {{ entry.takeoff_airport.name }}
{% elif entry.landing_airport is not none and entry.landing_airport.id|string() != sel_airport %}Landing: {{ entry.landing_airport.name }}
diff --git a/ogn_python/templates/receiver_detail.html b/ogn_python/templates/receiver_detail.html
index d53639f..69e4c5f 100644
--- a/ogn_python/templates/receiver_detail.html
+++ b/ogn_python/templates/receiver_detail.html
@@ -11,6 +11,12 @@
Receiver Details
Name: | {{ receiver.name }} |
+ Airport: |
+ {% if airport is not none %}
+ {% if airport.takeoff_landings %}{{ airport.name }}{% else %}{{ airport.name }}{% endif %}
+ {% else %}-{% endif %}
+ |
+
Version: | {{ receiver.version }} |
Platform: | {{ receiver.platform }} |
First seen: | {{ receiver.firstseen }} |
@@ -18,31 +24,6 @@
-
-
- Nearby Airports
-
-
-
- Name |
- Distance |
-
-
-
-
- {% for tupel in near_airports %}
- {% set airport = tupel[0] %}
- {% set distance = tupel[1] %}
-
- {% if airport.takeoff_landings %}{{ airport.name }}{% else %}{{ airport.name }}{% endif %} |
- {{ '%0.1f'|format(distance/1000) }} km |
-
- {% endfor %}
-
-
-
-
-
{% endblock %}
\ No newline at end of file
|