From 6ff07a7ba0a4963f1b09458e814d5f0dceffecd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Gru=CC=88ndger?= Date: Wed, 3 Apr 2019 22:35:33 +0200 Subject: [PATCH] Added DeviceInfos in device detail view --- ogn_python/model/device.py | 8 ++++++++ ogn_python/templates/device_detail.html | 24 +++++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/ogn_python/model/device.py b/ogn_python/model/device.py index e6e7f63..f668655 100644 --- a/ogn_python/model/device.py +++ b/ogn_python/model/device.py @@ -39,6 +39,14 @@ class Device(db.Model): return query.first() + # Todo: remove FK from DeviceInfo + def get_infos(self): + query = db.session.query(DeviceInfo) \ + .filter(DeviceInfo.address == self.address) \ + .order_by(DeviceInfo.address_origin) + + return [info for info in query.all()] + EXPIRY_DATES = { 6.67: datetime.date(2020, 10, 31), 6.63: datetime.date(2020, 5, 31), diff --git a/ogn_python/templates/device_detail.html b/ogn_python/templates/device_detail.html index 8c3063d..f47d9fd 100644 --- a/ogn_python/templates/device_detail.html +++ b/ogn_python/templates/device_detail.html @@ -19,6 +19,28 @@ +
+

Device Info

+ + + + + + + + + + {% for info in device.get_infos() %} + + + + + + {% endfor %} + +
AircraftRegistrationCompetition SignAircraft TypeSource
{{ info.aircraft }}{{ info.registration }}{{ info.competition }}{{ info.aircraft_type }}{{ info.address_origin }}
-{% endblock %} \ No newline at end of file + + +{% endblock %}