Compare commits

..

2 commits

Author SHA1 Message Date
Edward Betts 6475692db1 Consider accommodation for trip end date 2024-01-23 15:56:23 +00:00
Edward Betts 72e7945fbe Change layout of trip page 2024-01-23 15:55:49 +00:00
3 changed files with 129 additions and 58 deletions

View file

@ -35,6 +35,8 @@ class Conference:
longitude: float | None = None
cfp_end: date | None = None
cfp_url: str | None = None
free: bool | None = None
hackathon: bool | None = None
@property
def display_name(self) -> str:

View file

@ -56,7 +56,14 @@ class Trip:
travel_end = max(arrive) if arrive else datetime.date.min
assert isinstance(travel_end, datetime.date)
max_date = max(max_conference_end, travel_end)
accommodation_end = (
max(as_date(item["to"]) for item in self.accommodation)
if self.accommodation
else datetime.date.min
)
assert isinstance(accommodation_end, datetime.date)
max_date = max(max_conference_end, travel_end, accommodation_end)
return max_date if max_date != datetime.date.min else None
@property

View file

@ -44,7 +44,7 @@
}
#map {
height: 80vh;
height: 90vh;
}
</style>
@ -53,75 +53,138 @@
{% set end = trip.end %}
{% block content %}
<div class="p-2">
<h1>{{ trip.title }}<small class="text-muted">({{ display_date(trip.start) }})</small></h1>
<div>Countries: {{ trip.countries_str }}</div>
{% if end %}
<div>
Dates: {{ display_date_no_year(trip.start) }} to {{ display_date_no_year(end) }}
({{ (end - trip.start).days }} nights)
<div class="row">
<div class="col m-3">
<h1>{{ trip.title }}</h1>
<p class="lead">
{% if end %}
{{ display_date_no_year(trip.start) }} to {{ display_date_no_year(end) }}
({{ (end - trip.start).days }} nights)
{% else %}
{{ display_date_no_year(trip.start) }} (end date missing)
{% endif %}
</p>
<div class="mb-3">
<div>Countries: {{ trip.countries_str }}</div>
{% set delta = human_readable_delta(trip.start) %}
{% if delta %}
<div>How long until trip: {{ delta }}</div>
{% endif %}
</div>
{% else %}
<div>Start: {{ display_date_no_year(trip.start) }} (end date missing)</div>
{% endif %}
{% set delta = human_readable_delta(trip.start) %}
{% if delta %}
<div>{{ delta }} time</div>
{% endif %}
{% for item in trip.conferences %}
{% set country = get_country(item.country) if item.country else None %}
<div class="card my-1">
<div class="card-body">
<h5 class="card-title">
<a href="{{ item.url }}">{{ item.name }}</a>
<small class="text-muted">
{{ display_date_no_year(item.start) }} to {{ display_date_no_year(item.end) }}
</small>
</h5>
<p class="card-text">
Topic: {{ item.topic }}
| Venue: {{ item.venue }}
| Location: {{ item.location }}
{% if country %}
{{ country.flag }}
{% elif item.online %}
💻 Online
{% else %}
<span class="text-bg-danger p-2">
country code <strong>{{ item.country }}</strong> not found
</span>
{% endif %}
{% if item.free %}
| <span class="badge bg-success text-nowrap">free to attend</span>
{% elif item.price and item.currency %}
| <span class="badge bg-info text-nowrap">price: {{ item.price }} {{ item.currency }}</span>
{% endif %}
</p>
</div>
</div>
{% endfor %}
<div class="conferences">
{% for conf in trip.conferences %} {{ conference_row(conf, "going") }} {% endfor %}
</div>
{% for item in trip.accommodation %}
{% set country = get_country(item.country) if item.country else None %}
{% set nights = (item.to.date() - item.from.date()).days %}
<div class="card my-1">
<div class="card-body">
<h5 class="card-title">
{% if item.operator %}{{ item.operator }}: {% endif %}
<a href="{{ item.url }}">{{ item.name }}</a>
<small class="text-muted">
{{ display_date_no_year(item.from) }} to {{ display_date_no_year(item.to) }}
({% if nights == 1 %}1 night{% else %}{{ nights }} nights{% endif %})
</small>
</h5>
<p class="card-text">
Address: {{ item.address }}
| Location: {{ item.location }}
{% if country %}
{{ country.flag }}
{% elif item.online %}
💻 Online
{% else %}
<span class="text-bg-danger p-2">
country code <strong>{{ item.country }}</strong> not found
</span>
{% endif %}
{% if item.price and item.currency %}
| <span class="badge bg-info text-nowrap">price: {{ item.price }} {{ item.currency }}</span>
{% endif %}
</p>
</div>
</div>
{% endfor %}
<div class="accommodation">
{% for conf in trip.accommodation %} {{ accommodation_row(conf, "going") }} {% endfor %}
</div>
<div class="travel">
{% for item in trip.travel %} {{ row[item.type](item) }} {% endfor %}
</div>
<div class="travel">
{% for item in trip.travel %} {{ row[item.type](item) }} {% endfor %}
</div>
<div class="mt-3">
<h4>Holidays</h4>
{% if holidays %}
{% if holidays %}
<div class="mt-3">
<h4>Holidays</h4>
<table class="table table-hover w-auto">
{% for item in holidays %}
{% set country = get_country(item.country) %}
<tr>
{% if loop.first or item.date != loop.previtem.date %}
<td class="text-end">{{ display_date(item.date) }}</td>
{% else %}
<td></td>
{% endif %}
<td>{{ country.flag }} {{ country.name }}</td>
<td>{{ item.display_name }}</td>
</tr>
{% endfor %}
</table>
{% else %}
<p>No public holidays during trip.</p>
{% endif %}
</div>
<table class="table table-hover w-auto">
{% for item in holidays %}
{% set country = get_country(item.country) %}
<tr>
{% if loop.first or item.date != loop.previtem.date %}
<td class="text-end">{{ display_date(item.date) }}</td>
{% else %}
<td></td>
<p>
{% if prev_trip %}
previous: {{ trip_link(prev_trip) }} ({{ (trip.start - prev_trip.end).days }} days)
{% endif %}
<td>{{ country.flag }} {{ country.name }}</td>
<td>{{ item.display_name }}</td>
</tr>
{% endfor %}
</table>
{% if next_trip %}
next: {{ trip_link(next_trip) }} ({{ (next_trip.start - trip.end).days }} days)
{% endif %}
</p>
</div>
<div class="col">
<div id="map"></div>
</div>
{% endif %}
<p>
{% if prev_trip %}
previous: {{ trip_link(prev_trip) }} ({{ (trip.start - prev_trip.end).days }} days)
{% endif %}
{% if next_trip %}
next: {{ trip_link(next_trip) }} ({{ (next_trip.start - trip.end).days }} days)
{% endif %}
</p>
{% if coordinates %}
<div id="map"></div>
{% endif %}
</div>
{% endblock %}
{% block scripts %}
{% if coordinates %}
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"
integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo="
crossorigin=""></script>
@ -137,5 +200,4 @@ var routes = {{ routes | tojson }};
build_map("map", coordinates, routes);
</script>
{% endif %}
{% endblock %}