Compare commits

...

4 commits

Author SHA1 Message Date
Edward Betts 4c651198f3 Add birthday list page 2024-06-03 19:30:14 +01:00
Edward Betts 733608bc2f Fix spelling 2024-06-02 19:05:04 +01:00
Edward Betts 5de5e22883 Fix docstrings 2024-06-02 19:04:37 +01:00
Edward Betts ade6989300 Show links to flight data web sites 2024-06-02 19:01:18 +01:00
8 changed files with 45 additions and 6 deletions

View file

@ -1,4 +1,4 @@
"""Accomodation""" """Accommodation."""
import yaml import yaml
@ -6,7 +6,7 @@ from .types import Event
def get_events(filepath: str) -> list[Event]: def get_events(filepath: str) -> list[Event]:
"""Get accomodation from YAML.""" """Get accommodation from YAML."""
with open(filepath) as f: with open(filepath) as f:
return [ return [
Event( Event(

View file

@ -1,4 +1,4 @@
"""Calcuate the date for carnival.""" """Calculate the date for carnival."""
from datetime import date, timedelta from datetime import date, timedelta

View file

@ -42,7 +42,7 @@ here = dateutil.tz.tzlocal()
# deadline to file tax return # deadline to file tax return
# credit card expiry dates # credit card expiry dates
# morzine ski lifts # morzine ski lifts
# chalet availablity calendar # chalet availability calendar
# starlink visible # starlink visible

View file

@ -1,4 +1,4 @@
"""Accomodation.""" """Domain renewal dates."""
import csv import csv
import os import os

View file

@ -0,0 +1,17 @@
{% extends "base.html" %}
{% from "macros.html" import display_date %}
{% block title %}Birthdays - Edward Betts{% endblock %}
{% block content %}
<div class="container-fluid mt-2">
<h1>Birthdays</h1>
<table class="w-auto table">
{% for event in items %}
<tr>
<td class="text-end">{{event.as_date.strftime("%a, %d, %b")}}</td>
<td>{{ event.title }}</td>
</tr>
{% endfor %}
</table>
</div>
{% endblock %}

View file

@ -11,7 +11,9 @@
{"endpoint": "weekends", "label": "Weekend" }, {"endpoint": "weekends", "label": "Weekend" },
{"endpoint": "launch_list", "label": "Space launch" }, {"endpoint": "launch_list", "label": "Space launch" },
{"endpoint": "holiday_list", "label": "Holiday" }, {"endpoint": "holiday_list", "label": "Holiday" },
] %} ] + ([{"endpoint": "birthday_list", "label": "Birthdays" }]
if g.user.is_authenticated else [])
%}
<nav class="navbar navbar-expand-md bg-success" data-bs-theme="dark"> <nav class="navbar navbar-expand-md bg-success" data-bs-theme="dark">

View file

@ -124,6 +124,8 @@
&ndash; &ndash;
{{ e.end_loc }} {{ e.end_country.flag }} {{ e.end_loc }} {{ e.end_country.flag }}
{% if e.element_type == "flight" %} {% if e.element_type == "flight" %}
{% set full_flight_number = e.detail.airline + e.detail.flight_number %}
{% set radarbox_url = "https://www.radarbox.com/data/flights/" + full_flight_number %}
<span class="text-nowrap"><strong>airline:</strong> {{ e.detail.airline_name }}</span> <span class="text-nowrap"><strong>airline:</strong> {{ e.detail.airline_name }}</span>
<span class="text-nowrap"><strong>flight number:</strong> {{ e.detail.airline }}{{ e.detail.flight_number }}</span> <span class="text-nowrap"><strong>flight number:</strong> {{ e.detail.airline }}{{ e.detail.flight_number }}</span>
{% if e.detail.duration %} {% if e.detail.duration %}
@ -134,6 +136,11 @@
{% if e.detail.distance %} {% if e.detail.distance %}
<span class="text-nowrap"><strong>distance:</strong> {{ format_distance(e.detail.distance) }}</span> <span class="text-nowrap"><strong>distance:</strong> {{ format_distance(e.detail.distance) }}</span>
{% endif %} {% endif %}
{% if e.element_type == "flight" %}
<a href="https://www.flightradar24.com/data/flights/{{ full_flight_number | lower }}">flightradar24</a>
| <a href="https://uk.flightaware.com/live/flight/{{ full_flight_number | replace("U2", "EZY") }}">FlightAware</a>
| <a href="{{ radarbox_url }}">radarbox</a>
{% endif %}
</div> </div>
{% endif %} {% endif %}
{% endfor %} {% endfor %}

View file

@ -496,6 +496,19 @@ def holiday_list() -> str:
) )
@app.route("/birthdays")
def birthday_list() -> str:
"""List of birthdays."""
today = date.today()
if not flask.g.user.is_authenticated:
flask.abort(401)
data_dir = app.config["PERSONAL_DATA"]
entities_file = os.path.join(data_dir, "entities.yaml")
items = agenda.birthday.get_birthdays(today - timedelta(days=2), entities_file)
items.sort(key=lambda item: item.date)
return flask.render_template("birthday_list.html", items=items, today=today)
@app.route("/callback") @app.route("/callback")
def auth_callback() -> tuple[str, int] | werkzeug.Response: def auth_callback() -> tuple[str, int] | werkzeug.Response:
"""Process the authentication callback.""" """Process the authentication callback."""