From 7ce03fbf6f9aa3cec9aa147b012627c8be92d137 Mon Sep 17 00:00:00 2001 From: Ed Date: Fri, 12 May 2023 00:17:45 +0200 Subject: [PATCH] Improvement to carpooling (now can set to and fixes) --- carpooling.py | 5 ++++- tpl/carpooling.html | 9 +++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/carpooling.py b/carpooling.py index 50e48ba..03f5a82 100644 --- a/carpooling.py +++ b/carpooling.py @@ -28,7 +28,7 @@ async def carpooling_update(request, order: Order): payload = {} for field in ['from_location', 'offer_or_need', 'day_departure', 'message']: val = request.form.get(field) - if not val: + if not val and field != 'to_location': error = f"One of the forms contains invalid values. ({field})" elif len(val) > 64 and field != 'message': error = "One of the forms contains too long values." @@ -40,6 +40,9 @@ async def carpooling_update(request, order: Order): error = "Please do not use more than 6 line breaks in the message!" else: payload[field] = val + + if request.form.get('to_location'): + payload['to_location'] = request.form.get('to_location') if not error: order.carpooling_message = payload diff --git a/tpl/carpooling.html b/tpl/carpooling.html index a51ec29..6a60f1f 100644 --- a/tpl/carpooling.html +++ b/tpl/carpooling.html @@ -9,12 +9,13 @@

Welcome to the carpooling page! Here you can see all of the available seats of other people attending the con. Use the form below to report if you want to offer a ride yourself or are looking for one!

+

ℹ️ Did you know? Now you can also offer rides and change the destination!

{% if error %}

⚠️ {{error}}

{% endif %}
- +
@@ -25,8 +26,8 @@
@@ -61,7 +62,7 @@ {% endif %} {% for o in orders %}
-

{{o.name}} {{'is offering' if o.carpooling_message.offer_or_need == 'offer' else 'needs'}} a trip from {{o.carpooling_message.from_location}} on the {{o.carpooling_message.day_departure[1:]}} of {{'May' if o.carpooling_message.day_departure[0] == 'm' else 'June'}}.

+

{{o.name}} {{'is offering' if o.carpooling_message.offer_or_need == 'offer' else 'needs'}} a trip from {{o.carpooling_message.from_location}} {% if o.carpooling_message.to_location %}to {{o.carpooling_message.to_location}}{% endif %} on the {{o.carpooling_message.day_departure[1:]}} of {{'May' if o.carpooling_message.day_departure[0] == 'm' else 'June'}}.

{{o.carpooling_message.message|escape|replace("\n", "
"|safe)}}