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 longitude: float | None = None
cfp_end: date | None = None cfp_end: date | None = None
cfp_url: str | None = None cfp_url: str | None = None
free: bool | None = None
hackathon: bool | None = None
@property @property
def display_name(self) -> str: def display_name(self) -> str:

View file

@ -56,7 +56,14 @@ class Trip:
travel_end = max(arrive) if arrive else datetime.date.min travel_end = max(arrive) if arrive else datetime.date.min
assert isinstance(travel_end, datetime.date) 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 return max_date if max_date != datetime.date.min else None
@property @property

View file

@ -44,7 +44,7 @@
} }
#map { #map {
height: 80vh; height: 90vh;
} }
</style> </style>
@ -53,75 +53,138 @@
{% set end = trip.end %} {% set end = trip.end %}
{% block content %} {% block content %}
<div class="p-2"> <div class="row">
<h1>{{ trip.title }}<small class="text-muted">({{ display_date(trip.start) }})</small></h1> <div class="col m-3">
<div>Countries: {{ trip.countries_str }}</div> <h1>{{ trip.title }}</h1>
{% if end %} <p class="lead">
<div> {% if end %}
Dates: {{ display_date_no_year(trip.start) }} to {{ display_date_no_year(end) }} {{ display_date_no_year(trip.start) }} to {{ display_date_no_year(end) }}
({{ (end - trip.start).days }} nights) ({{ (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> </div>
{% else %}
<div>Start: {{ display_date_no_year(trip.start) }} (end date missing)</div>
{% endif %}
{% set delta = human_readable_delta(trip.start) %} {% for item in trip.conferences %}
{% if delta %} {% set country = get_country(item.country) if item.country else None %}
<div>{{ delta }} time</div> <div class="card my-1">
{% endif %} <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 item in trip.accommodation %}
{% for conf in trip.conferences %} {{ conference_row(conf, "going") }} {% endfor %} {% set country = get_country(item.country) if item.country else None %}
</div> {% 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"> <div class="travel">
{% for conf in trip.accommodation %} {{ accommodation_row(conf, "going") }} {% endfor %} {% for item in trip.travel %} {{ row[item.type](item) }} {% endfor %}
</div> </div>
<div class="travel"> <div class="mt-3">
{% for item in trip.travel %} {{ row[item.type](item) }} {% endfor %} <h4>Holidays</h4>
</div> {% if holidays %}
{% if holidays %} <table class="table table-hover w-auto">
<div class="mt-3"> {% for item in holidays %}
<h4>Holidays</h4> {% 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"> <p>
{% for item in holidays %} {% if prev_trip %}
{% set country = get_country(item.country) %} previous: {{ trip_link(prev_trip) }} ({{ (trip.start - prev_trip.end).days }} days)
<tr>
{% if loop.first or item.date != loop.previtem.date %}
<td class="text-end">{{ display_date(item.date) }}</td>
{% else %}
<td></td>
{% endif %} {% endif %}
<td>{{ country.flag }} {{ country.name }}</td> {% if next_trip %}
<td>{{ item.display_name }}</td> next: {{ trip_link(next_trip) }} ({{ (next_trip.start - trip.end).days }} days)
</tr> {% endif %}
{% endfor %} </p>
</table>
</div>
<div class="col">
<div id="map"></div>
</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> </div>
{% endblock %} {% endblock %}
{% block scripts %} {% block scripts %}
{% if coordinates %}
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js" <script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"
integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo="
crossorigin=""></script> crossorigin=""></script>
@ -137,5 +200,4 @@ var routes = {{ routes | tojson }};
build_map("map", coordinates, routes); build_map("map", coordinates, routes);
</script> </script>
{% endif %}
{% endblock %} {% endblock %}