Highlight today in conference list
This commit is contained in:
parent
8cc8e3f9d3
commit
0fa6a2cdda
2 changed files with 21 additions and 2 deletions
13
web_view.py
13
web_view.py
|
|
@ -3,6 +3,7 @@
|
|||
"""Web page to show upcoming events."""
|
||||
|
||||
import inspect
|
||||
import operator
|
||||
import os.path
|
||||
import sys
|
||||
import traceback
|
||||
|
|
@ -79,10 +80,18 @@ def conference_list() -> str:
|
|||
data_dir = config["data"]["personal-data"]
|
||||
filepath = os.path.join(data_dir, "conferences.yaml")
|
||||
item_list = yaml.safe_load(open(filepath))["conferences"]
|
||||
today = date.today()
|
||||
for conf in item_list:
|
||||
conf["as_date"] = as_date(conf["start"])
|
||||
|
||||
item_list.sort(key=lambda conf: as_date(conf["start"]))
|
||||
item_list.sort(key=operator.itemgetter("as_date"))
|
||||
|
||||
return flask.render_template("conference_list.html", item_list=item_list)
|
||||
past = [conf for conf in item_list if conf["as_date"] < today]
|
||||
future = [conf for conf in item_list if conf["as_date"] >= today]
|
||||
|
||||
return flask.render_template(
|
||||
"conference_list.html", item_list=past + ["today"] + future, today=today
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue