From e2afe0ffa455b4c37bfb7cb9022b65b44b9cceee Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Wed, 17 Apr 2024 11:40:13 +0100 Subject: [PATCH] Show prices for logged in users Trip prices are visible on trip list, accommodation list, conference list and travel list. Prices are hidden if not logged in, except conference prices. Still need to show prices on individual trip page. --- agenda/trip.py | 11 +++++++++++ templates/accommodation.html | 2 +- templates/conference_list.html | 2 +- templates/macros.html | 20 ++++++++++++++++++++ templates/travel.html | 8 ++++++-- templates/trip_list.html | 6 +++--- web_view.py | 11 +++++++++++ 7 files changed, 53 insertions(+), 7 deletions(-) diff --git a/agenda/trip.py b/agenda/trip.py index 837deb4..a5f3537 100644 --- a/agenda/trip.py +++ b/agenda/trip.py @@ -1,5 +1,6 @@ """Trips.""" +import decimal import os import typing from datetime import date, datetime, time @@ -100,6 +101,11 @@ def build_trip_list( key=depart_datetime, ) + for item in travel_items: + price = item.get("price") + if price: + item["price"] = decimal.Decimal(price) + data = { "travel": travel_items, "accommodation": travel.parse_yaml("accommodation", data_dir), @@ -107,6 +113,11 @@ def build_trip_list( "events": travel.parse_yaml("events", data_dir), } + for item in data["accommodation"]: + price = item.get("price") + if price: + item["price"] = decimal.Decimal(price) + for key, item_list in data.items(): assert isinstance(item_list, list) for item in item_list: diff --git a/templates/accommodation.html b/templates/accommodation.html index cd65dea..1df44fa 100644 --- a/templates/accommodation.html +++ b/templates/accommodation.html @@ -2,7 +2,7 @@ {% from "macros.html" import trip_link, accommodation_row with context %} {% block title %}Accommodation - Edward Betts{% endblock %} {% block style %} -{% set column_count = 8 %} +{% set column_count = 9 %}