Link from conference list to trip pages

This commit is contained in:
Edward Betts 2024-01-14 17:23:50 +00:00
parent 36168843d6
commit 31e8197c79
3 changed files with 19 additions and 5 deletions

View file

@ -1,9 +1,9 @@
{% extends "base.html" %}
{% from "macros.html" import conference_row with context %}
{% from "macros.html" import trip_link, conference_row with context %}
{% block style %}
{% set column_count = 6 %}
{% set column_count = 7 %}
<style>
.grid-container {
display: grid;
@ -25,7 +25,10 @@
{% macro section(heading, item_list, badge) %}
{% if item_list %}
<div class="heading"><h2>{{ heading }}</h2></div>
{% for item in item_list %}{{ conference_row(item, badge) }}{% endfor %}
{% for item in item_list %}
{{ conference_row(item, badge) }}
<div class="grid-item">{% if item.trip %} trip: {{ trip_link(item.trip) }} {% endif %}</div>
{% endfor %}
{% endif %}
{% endmacro %}

View file

@ -1,6 +1,6 @@
{% extends "base.html" %}
{% from "macros.html" import display_date_no_year, display_date, conference_row, accommodation_row, flight_row, train_row with context %}
{% from "macros.html" import trip_link, display_date_no_year, display_date, conference_row, accommodation_row, flight_row, train_row with context %}
{% set row = { "flight": flight_row, "train": train_row } %}
@ -57,7 +57,7 @@
{% set end = trip.end %}
<div class="border border-2 rounded mb-2 p-2">
<h3>
<a href="{{ url_for("trip_page", start=trip.start.isoformat()) }}">{{ trip.title }}</a>
{{ trip_link(trip) }}
<small class="text-muted">({{ display_date(trip.start) }})</small></h3>
<div>Countries: {{ trip.countries_str }}</div>
{% if end %}

View file

@ -104,10 +104,21 @@ def conference_list() -> str:
filepath = os.path.join(data_dir, "conferences.yaml")
item_list = yaml.safe_load(open(filepath))
today = date.today()
trip_list = agenda.trip.build_trip_list()
conference_trip_lookup = {}
for trip in trip_list:
for trip_conf in trip.conferences:
key = (trip_conf["start"], trip_conf["name"])
conference_trip_lookup[key] = trip
for conf in item_list:
conf["start_date"] = as_date(conf["start"])
conf["end_date"] = as_date(conf["end"])
key = (conf["start"], conf["name"])
if this_trip := conference_trip_lookup.get(key):
conf["trip"] = this_trip
item_list.sort(key=operator.itemgetter("start_date"))
current = [