Compare commits
2 commits
37be85593b
...
b1507702cf
Author | SHA1 | Date | |
---|---|---|---|
Edward Betts | b1507702cf | ||
Edward Betts | 291b545915 |
|
@ -42,7 +42,9 @@
|
|||
</ul>
|
||||
|
||||
<div class="grid-container">
|
||||
{{ section("Accommodation", items) }}
|
||||
{{ section("Past", past) }}
|
||||
{{ section("Current", current) }}
|
||||
{{ section("Future", future) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
25
web_view.py
25
web_view.py
|
@ -21,7 +21,7 @@ import agenda.error_mail
|
|||
import agenda.holidays
|
||||
import agenda.thespacedevs
|
||||
import agenda.trip
|
||||
from agenda import format_list_with_ampersand, travel
|
||||
from agenda import format_list_with_ampersand, travel, uk_tz
|
||||
from agenda.types import StrDict
|
||||
|
||||
app = flask.Flask(__name__)
|
||||
|
@ -139,7 +139,7 @@ def conference_list() -> str:
|
|||
"""Page showing a list of conferences."""
|
||||
data_dir = app.config["PERSONAL_DATA"]
|
||||
filepath = os.path.join(data_dir, "conferences.yaml")
|
||||
item_list = yaml.safe_load(open(filepath))
|
||||
items = yaml.safe_load(open(filepath))
|
||||
today = date.today()
|
||||
|
||||
conference_trip_lookup = {}
|
||||
|
@ -148,7 +148,7 @@ def conference_list() -> str:
|
|||
key = (trip_conf["start"], trip_conf["name"])
|
||||
conference_trip_lookup[key] = trip
|
||||
|
||||
for conf in item_list:
|
||||
for conf in items:
|
||||
conf["start_date"] = as_date(conf["start"])
|
||||
conf["end_date"] = as_date(conf["end"])
|
||||
|
||||
|
@ -156,16 +156,15 @@ def conference_list() -> str:
|
|||
if this_trip := conference_trip_lookup.get(key):
|
||||
conf["linked_trip"] = this_trip
|
||||
|
||||
item_list.sort(key=operator.itemgetter("start_date"))
|
||||
items.sort(key=operator.itemgetter("start_date"))
|
||||
|
||||
past = [conf for conf in items if conf["end_date"] < today]
|
||||
current = [
|
||||
conf
|
||||
for conf in item_list
|
||||
for conf in items
|
||||
if conf["start_date"] <= today and conf["end_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]
|
||||
future = [conf for conf in items if conf["start_date"] > today]
|
||||
|
||||
return flask.render_template(
|
||||
"conference_list.html",
|
||||
|
@ -206,9 +205,17 @@ def accommodation_list() -> str:
|
|||
if this_trip := trip_lookup.get(key):
|
||||
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(
|
||||
"accommodation.html",
|
||||
items=items,
|
||||
past=past,
|
||||
current=current,
|
||||
future=future,
|
||||
total_nights_2024=total_nights_2024,
|
||||
nights_abroad_2024=nights_abroad_2024,
|
||||
get_country=agenda.get_country,
|
||||
|
|
Loading…
Reference in a new issue