Compare commits

..

No commits in common. "b1507702cf3df3d23b70146f38db4209e70d8bf0" and "37be85593b7c8643fb6f0ac451e4a156aaeef91a" have entirely different histories.

2 changed files with 10 additions and 19 deletions

View file

@ -42,9 +42,7 @@
</ul> </ul>
<div class="grid-container"> <div class="grid-container">
{{ section("Past", past) }} {{ section("Accommodation", items) }}
{{ section("Current", current) }}
{{ section("Future", future) }}
</div> </div>
</div> </div>

View file

@ -21,7 +21,7 @@ import agenda.error_mail
import agenda.holidays import agenda.holidays
import agenda.thespacedevs import agenda.thespacedevs
import agenda.trip import agenda.trip
from agenda import format_list_with_ampersand, travel, uk_tz from agenda import format_list_with_ampersand, travel
from agenda.types import StrDict from agenda.types import StrDict
app = flask.Flask(__name__) app = flask.Flask(__name__)
@ -139,7 +139,7 @@ def conference_list() -> str:
"""Page showing a list of conferences.""" """Page showing a list of conferences."""
data_dir = app.config["PERSONAL_DATA"] data_dir = app.config["PERSONAL_DATA"]
filepath = os.path.join(data_dir, "conferences.yaml") filepath = os.path.join(data_dir, "conferences.yaml")
items = yaml.safe_load(open(filepath)) item_list = yaml.safe_load(open(filepath))
today = date.today() today = date.today()
conference_trip_lookup = {} conference_trip_lookup = {}
@ -148,7 +148,7 @@ def conference_list() -> str:
key = (trip_conf["start"], trip_conf["name"]) key = (trip_conf["start"], trip_conf["name"])
conference_trip_lookup[key] = trip conference_trip_lookup[key] = trip
for conf in items: for conf in item_list:
conf["start_date"] = as_date(conf["start"]) conf["start_date"] = as_date(conf["start"])
conf["end_date"] = as_date(conf["end"]) conf["end_date"] = as_date(conf["end"])
@ -156,15 +156,16 @@ def conference_list() -> str:
if this_trip := conference_trip_lookup.get(key): if this_trip := conference_trip_lookup.get(key):
conf["linked_trip"] = this_trip conf["linked_trip"] = this_trip
items.sort(key=operator.itemgetter("start_date")) item_list.sort(key=operator.itemgetter("start_date"))
past = [conf for conf in items if conf["end_date"] < today]
current = [ current = [
conf conf
for conf in items for conf in item_list
if conf["start_date"] <= today and conf["end_date"] >= today if conf["start_date"] <= today and conf["end_date"] >= today
] ]
future = [conf for conf in items if conf["start_date"] > today]
past = [conf for conf in item_list if conf["end_date"] < today]
future = [conf for conf in item_list if conf["start_date"] > today]
return flask.render_template( return flask.render_template(
"conference_list.html", "conference_list.html",
@ -205,17 +206,9 @@ def accommodation_list() -> str:
if this_trip := trip_lookup.get(key): if this_trip := trip_lookup.get(key):
item["linked_trip"] = this_trip item["linked_trip"] = this_trip
now = uk_tz.localize(datetime.now())
past = [conf for conf in items if conf["to"] < now]
current = [conf for conf in items if conf["from"] <= now and conf["to"] >= now]
future = [conf for conf in items if conf["from"] > now]
return flask.render_template( return flask.render_template(
"accommodation.html", "accommodation.html",
past=past, items=items,
current=current,
future=future,
total_nights_2024=total_nights_2024, total_nights_2024=total_nights_2024,
nights_abroad_2024=nights_abroad_2024, nights_abroad_2024=nights_abroad_2024,
get_country=agenda.get_country, get_country=agenda.get_country,