pull/78/head
Konstantin Gründger 2020-12-05 21:24:51 +01:00
rodzic e888481843
commit 5bd2d7db13
9 zmienionych plików z 30 dodań i 14 usunięć

Wyświetl plik

@ -1,11 +1,26 @@
from app.main import bp
from app.model import Airport, Sender, Receiver
from app.model import Airport, Country, Sender, Receiver
from flask import url_for
import datetime
import math
@bp.app_template_filter()
def to_html_flag(obj):
if obj is None:
return ""
if isinstance(obj, str):
return f"""<img src="{url_for('static', filename='img/Transparent.gif')}" class="flag flag-{obj.lower()}" alt="{obj}"/>"""
elif isinstance(obj, Airport):
return f"""<img src="{url_for('static', filename='img/Transparent.gif')}" class="flag flag-{obj.country_code.lower()}" alt="{obj.country_code}"/>"""
elif isinstance(obj, Country):
return f"""<img src="{url_for('static', filename='img/Transparent.gif')}" class="flag flag-{obj.iso2.lower()}" alt="{obj.iso2}"/>"""
@bp.app_template_filter()
def to_html_link(obj):
if isinstance(obj, Airport):

Wyświetl plik

@ -135,8 +135,8 @@ def update_statistics(date_str=None):
db.session.execute(f"""
UPDATE receiver_rankings AS rr
SET
longtime_global_rank_delta = rr.longtime_global_rank - sq.longtime_global_rank_yesterday,
longtime_local_rank_delta = rr.longtime_local_rank - sq.longtime_local_rank_yesterday
longtime_global_rank_delta = sq.longtime_global_rank_yesterday - rr.longtime_global_rank,
longtime_local_rank_delta = sq.longtime_local_rank_yesterday - rr.longtime_local_rank
FROM (
SELECT
rr.receiver_id,

Wyświetl plik

@ -9,7 +9,7 @@
<div class="panel panel-success">
<div class="panel-heading"><h3 class="panel-title">Airport Details</h3></div>
<table class="datatable table table-striped table-bordered">
<tr><td>Name:</td><td><img src="{{ url_for('static', filename='img/Transparent.gif') }}" class="flag flag-{{ airport.country_code|lower }}" alt="{{ airport.country_code }}"/> {{ airport.name }}</td></tr>
<tr><td>Name:</td><td>{{ airport|to_html_flag|safe }} {{ airport.name }}</td></tr>
<tr><td>Code:</td><td>{{ airport.code }}</td></tr>
<tr><td>Altitude:</td><td>{{ airport.altitude|int }} m</td></tr>
<tr><td>Style:</td><td>{{ airport.style }}</td></tr>

Wyświetl plik

@ -31,7 +31,7 @@
{% for airport in airports %}
<tr>
<td>{{ loop.index }}
<td><img src="{{ url_for('static', filename='img/Transparent.gif') }}" class="flag flag-{{ sel_country|lower }}" alt="{{ sel_country }}"/></td>
<td>{{ sel_country|to_html_flag|safe }}</td>
<td>{{ airport|to_html_link|safe }}</td>
<td><a href="{{ url_for('main.logbooks', country=sel_country, airport_id=airport.id) }}">Logbook</a></td>
</tr>

Wyświetl plik

@ -61,8 +61,8 @@
<td>{% if entry.duration is not none %}{{ entry.duration }}{% endif %}</td>
<td>{% if entry.max_altitude is not none %}{{ '%d' | format(entry.max_altitude - entry.takeoff_airport.altitude) }} m{% endif %}</td>
<td>
{% if entry.takeoff_airport is not none and entry.takeoff_airport.id != sel_airport_id %}Take Off: <img src="{{ url_for('static', filename='img/Transparent.gif') }}" class="flag flag-{{ entry.takeoff_airport.country_code|lower }}" alt="{{ entry.takeoff_airport.country_code }}"/> <a href="{{ url_for('main.logbooks', country=entry.takeoff_airport.country_code, airport_id=entry.takeoff_airport.id, date=sel_date) }}">{{ entry.takeoff_airport.name }}</a>
{% elif entry.landing_airport is not none and entry.landing_airport.id != sel_airport_id %}Landing: <img src="{{ url_for('static', filename='img/Transparent.gif') }}" class="flag flag-{{ entry.landing_airport.country_code|lower }}" alt="{{ entry.landing_airport.country_code }}"/> <a href="{{ url_for('main.logbooks', country=entry.takeoff_airport.country_code, airport_id=entry.landing_airport.id, date=sel_date) }}">{{ entry.landing_airport.name }}</a>
{% if entry.takeoff_airport is not none and entry.takeoff_airport.id != sel_airport_id %}Take Off: {{ entry.takeoff_airport|to_html_flag|safe }} <a href="{{ url_for('main.logbooks', country=entry.takeoff_airport.country_code, airport_id=entry.takeoff_airport.id, date=sel_date) }}">{{ entry.takeoff_airport.name }}</a>
{% elif entry.landing_airport is not none and entry.landing_airport.id != sel_airport_id %}Landing: {{ entry.landing_airport|to_html_flag|safe }} <a href="{{ url_for('main.logbooks', country=entry.takeoff_airport.country_code, airport_id=entry.landing_airport.id, date=sel_date) }}">{{ entry.landing_airport.name }}</a>
{% endif %}
</td>
</tr>

Wyświetl plik

@ -10,9 +10,9 @@
<div class="panel panel-success">
<div class="panel-heading"><h3 class="panel-title">Receiver Details</h3></div>
<table class="datatable table table-striped table-bordered">
<tr><td>Name:</td><td><img src="{{ url_for('static', filename='img/Transparent.gif') }}" class="flag flag-{{ receiver.country.iso2|lower }}" alt="{{ receiver.country.iso2 }}"/> {{ receiver.name }}</td></tr>
<tr><td>Name:</td><td>{{ receiver.country|to_html_flag|safe }} {{ receiver.name }}</td></tr>
<tr><td>Airport:</td>
<td>{% if receiver.airport is not none %}<img src="{{ url_for('static', filename='img/Transparent.gif') }}" class="flag flag-{{ receiver.airport.country_code|lower }}" alt="{{ receiver.airport.country_code }}"/>
<td>{% if receiver.airport is not none %}{{ receiver.airport|to_html_flag|safe }}
<a href="{{ url_for('main.airport_detail', airport_id=receiver.airport.id) }}">{{ receiver.airport.name }}</a>
{% else %}-{% endif %}
</td>

Wyświetl plik

@ -23,7 +23,7 @@
<table id="myTable" class="table table-striped table-bordered tablesorter tablesorter-bootstrap">
<thead>
<tr>
<th class="text-right">Total</th>
<th class="text-right" colspan="2">Rank</th>
<th class="text-right">Today</th>
<th>Name</th>
<th>Airport</th>
@ -43,9 +43,10 @@
{% set rank = entry.local_rank %}{% set longtime_rank = entry.longtime_local_rank %}{% set longtime_rank_delta = entry.longtime_local_rank_delta %}
{% endif %}
<tr>
<td class="text-right">{{ longtime_rank }} ({% if longtime_rank_delta is none or longtime_rank_delta == 0%}±0{% elif longtime_rank_delta > 0 %}<span class="text-success">+{{ longtime_rank_delta }}</span>{% else %}<span class="text-danger">{{ longtime_rank_delta }}</span>{% endif %})</td>
<td class="text-right">{{ longtime_rank }}</td>
<td class="text-right">{% if longtime_rank_delta is none %}{% elif longtime_rank_delta > 0 %}<span class="text-success"><i class="fa fa-long-arrow-up"></i>{{ longtime_rank_delta }}</span>{% elif longtime_rank_delta < 0 %}<span class="text-danger"><i class="fa fa-long-arrow-down"></i>{{ -longtime_rank_delta }}</span>{% endif %}</td>
<td class="text-right">{{ rank }}</td>
<td><img src="{{ url_for('static', filename='img/Transparent.gif') }}" class="flag flag-{{ entry.receiver.country.iso2|lower }}" alt="{{ entry.receiver.country.iso2 }}"/> {{ entry.receiver|to_html_link|safe }}</td>
<td>{{ entry.receiver.country|to_html_flag|safe }} {{ entry.receiver|to_html_link|safe }}</td>
<td>{{ entry.receiver.airport|to_html_link|safe }}</td>
<td class="text-right">{{ '%0.1f' | format(entry.max_distance/1000.0) }}</td>
<td class="text-right">{{ '%0.1f' | format(entry.max_normalized_quality) }}</td>

Wyświetl plik

@ -38,7 +38,7 @@
{% for receiver in receivers %}
<tr>
<td>{{ loop.index }}</td>
<td><img src="{{ url_for('static', filename='img/Transparent.gif') }}" class="flag flag-{{ receiver.country.iso2|lower }}" alt="{{ receiver.country.iso2 }}"/></td>
<td>{{ receiver.country|to_html_flag|safe }}</td>
<td>{{ receiver|to_html_link|safe }}</td>
<td>{{ receiver.airport|to_html_link|safe }}</td>
<td>{{ receiver.altitude|int }} m</td>

Wyświetl plik

@ -8,7 +8,7 @@
<table id="myTable" class="datatable table table-striped table-bordered">
<thead>
<tr>
<th>#</th>
<th>Rank</th>
<th>Name</th>
<th>Aircraft</th>
<th class="text-right">Maximum distance [km]</th>