Add birthday list page
This commit is contained in:
parent
733608bc2f
commit
4c651198f3
17
templates/birthday_list.html
Normal file
17
templates/birthday_list.html
Normal 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 %}
|
|
@ -11,7 +11,9 @@
|
|||
{"endpoint": "weekends", "label": "Weekend" },
|
||||
{"endpoint": "launch_list", "label": "Space launch" },
|
||||
{"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">
|
||||
|
|
13
web_view.py
13
web_view.py
|
@ -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")
|
||||
def auth_callback() -> tuple[str, int] | werkzeug.Response:
|
||||
"""Process the authentication callback."""
|
||||
|
|
Loading…
Reference in a new issue