parent
							
								
									21b67bdc64
								
							
						
					
					
						commit
						fd6d3b674b
					
				| 
						 | 
				
			
			@ -2,6 +2,8 @@
 | 
			
		|||
 | 
			
		||||
{% from "macros.html" import display_date_no_year, conference_row, accommodation_row, flight_row, train_row with context %}
 | 
			
		||||
 | 
			
		||||
{% set row = { "flight": flight_row, "train": train_row } %}
 | 
			
		||||
 | 
			
		||||
{% block style %}
 | 
			
		||||
{% set conference_column_count = 6 %}
 | 
			
		||||
{% set accommodation_column_count = 7 %}
 | 
			
		||||
| 
						 | 
				
			
			@ -34,42 +36,50 @@
 | 
			
		|||
</style>
 | 
			
		||||
{% endblock %}
 | 
			
		||||
 | 
			
		||||
{% macro section(heading, item_list, badge) %}
 | 
			
		||||
  {% if item_list %}
 | 
			
		||||
    <div class="heading"><h2>{{ heading }}</h2></div>
 | 
			
		||||
    {% for trip in item_list %}
 | 
			
		||||
      {% set end = trip.end %}
 | 
			
		||||
      <div class="border border-2 rounded mb-2 p-2">
 | 
			
		||||
        <h3>{{ trip.title }} <small class="text-muted">({{ trip.start.strftime("%b %Y") }})</small></h3>
 | 
			
		||||
        <div>Countries: {{ trip.countries_str }}</div>
 | 
			
		||||
        {% if end %}
 | 
			
		||||
          <div>Dates: {{ display_date_no_year(trip.start) }} to {{ display_date_no_year(end) }}</div>
 | 
			
		||||
        {% else %}
 | 
			
		||||
          <div>Start: {{ display_date_no_year(trip.start) }} (end date missing)</div>
 | 
			
		||||
        {% endif %}
 | 
			
		||||
        <div class="conferences">
 | 
			
		||||
        {% for conf in trip.conferences %}
 | 
			
		||||
          {{ conference_row(conf, "going") }}
 | 
			
		||||
        {% endfor %}
 | 
			
		||||
        </div>
 | 
			
		||||
 | 
			
		||||
        <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>
 | 
			
		||||
    {% endfor %}
 | 
			
		||||
  {% endif %}
 | 
			
		||||
{% endmacro %}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
{% block content %}
 | 
			
		||||
<div class="p-2">
 | 
			
		||||
 | 
			
		||||
  {% set row = { "flight": flight_row, "train": train_row } %}
 | 
			
		||||
 | 
			
		||||
  <h1>Trips</h1>
 | 
			
		||||
  {% for trip in trips %}
 | 
			
		||||
    {% set end = trip.end %}
 | 
			
		||||
    <div class="border border-2 rounded mb-2 p-2">
 | 
			
		||||
      <h3>{{ trip.title }} <small class="text-muted">({{ trip.start.strftime("%b %Y") }})</small></h3>
 | 
			
		||||
      <div>Countries: {{ trip.countries_str }}</div>
 | 
			
		||||
      {% if end %}
 | 
			
		||||
        <div>Dates: {{ display_date_no_year(trip.start) }} to {{ display_date_no_year(end) }}</div>
 | 
			
		||||
      {% else %}
 | 
			
		||||
        <div>Start: {{ display_date_no_year(trip.start) }} (end date missing)</div>
 | 
			
		||||
      {% endif %}
 | 
			
		||||
      <div class="conferences">
 | 
			
		||||
      {% for conf in trip.conferences %}
 | 
			
		||||
        {{ conference_row(conf, "going") }}
 | 
			
		||||
      {% endfor %}
 | 
			
		||||
      </div>
 | 
			
		||||
 | 
			
		||||
      <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>
 | 
			
		||||
  {% endfor %}
 | 
			
		||||
    {{ section("Current", current, "attending") }}
 | 
			
		||||
    {{ section("Future", future, "going") }}
 | 
			
		||||
    {{ section("Past", past|reverse, "went") }}
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
{% endblock %}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										28
									
								
								web_view.py
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								web_view.py
									
									
									
									
									
								
							| 
						 | 
				
			
			@ -164,9 +164,8 @@ def load_travel(travel_type: str) -> list[StrDict]:
 | 
			
		|||
    return items
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@app.route("/trip")
 | 
			
		||||
def trip_list() -> str:
 | 
			
		||||
    """Page showing a list of trips."""
 | 
			
		||||
def build_trip_list() -> list[Trip]:
 | 
			
		||||
    """Generate list of trips."""
 | 
			
		||||
    trips: dict[date, Trip] = {}
 | 
			
		||||
 | 
			
		||||
    data_dir = app.config["PERSONAL_DATA"]
 | 
			
		||||
| 
						 | 
				
			
			@ -190,11 +189,30 @@ def trip_list() -> str:
 | 
			
		|||
                trips[start] = Trip(start=start)
 | 
			
		||||
            getattr(trips[start], key).append(item)
 | 
			
		||||
 | 
			
		||||
    trip_list = [trip for _, trip in sorted(trips.items(), reverse=True)]
 | 
			
		||||
    return [trip for _, trip in sorted(trips.items())]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@app.route("/trip")
 | 
			
		||||
def trip_list() -> str:
 | 
			
		||||
    """Page showing a list of trips."""
 | 
			
		||||
    trip_list = build_trip_list()
 | 
			
		||||
 | 
			
		||||
    today = date.today()
 | 
			
		||||
    current = [
 | 
			
		||||
        item
 | 
			
		||||
        for item in trip_list
 | 
			
		||||
        if item.start <= today and (item.end or item.start) >= today
 | 
			
		||||
    ]
 | 
			
		||||
 | 
			
		||||
    past = [item for item in trip_list if (item.end or item.start) < today]
 | 
			
		||||
    future = [item for item in trip_list if item.start > today]
 | 
			
		||||
 | 
			
		||||
    return flask.render_template(
 | 
			
		||||
        "trips.html",
 | 
			
		||||
        trips=trip_list,
 | 
			
		||||
        current=current,
 | 
			
		||||
        past=past,
 | 
			
		||||
        future=future,
 | 
			
		||||
        today=today,
 | 
			
		||||
        get_country=agenda.get_country,
 | 
			
		||||
        format_list_with_ampersand=format_list_with_ampersand,
 | 
			
		||||
    )
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue