Improvement to carpooling (now can set to and fixes)
This commit is contained in:
parent
513360d06f
commit
7ce03fbf6f
|
@ -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."
|
||||
|
@ -41,6 +41,9 @@ async def carpooling_update(request, order: Order):
|
|||
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
|
||||
await order.edit_answer('carpooling_message', json.dumps(payload))
|
||||
|
|
|
@ -9,12 +9,13 @@
|
|||
</picture>
|
||||
</header>
|
||||
<p>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!</p>
|
||||
<p class="notice" style="background:var(--primary);">ℹ️ Did you know? Now you can also <strong>offer</strong> rides and change the destination!</p>
|
||||
<form action="" method="post">
|
||||
{% if error %}
|
||||
<p class="notice">⚠️ {{error}}</p>
|
||||
{% endif %}
|
||||
<section>
|
||||
<label for="switch"><input type="checkbox" id="wants_carpool" name="wants_carpool" role="switch" onchange="document.getElementById('tripform').style.display = this.checked?'initial':'none';" {{'checked' if order.carpooling_message else ''}}> I need to carpool</label>
|
||||
<label for="switch"><input type="checkbox" id="wants_carpool" name="wants_carpool" role="switch" onchange="document.getElementById('tripform').style.display = this.checked?'initial':'none';" {{'checked' if order.carpooling_message else ''}}> I want to offer or request a ride</label>
|
||||
</section>
|
||||
|
||||
<div id="tripform" style="{{'display:none;' if not order.carpooling_message else ''}}">
|
||||
|
@ -25,8 +26,8 @@
|
|||
<input type="text" id="from_location" name="from_location" placeholder="Example: Milan, Italy" value="{{order.carpooling_message.from_location}}" required>
|
||||
</label>
|
||||
<label for="to_location">
|
||||
Arrival
|
||||
<input type="text" id="to_location" name="to_location" value="Furizon, Cavalese" readonly>
|
||||
Arrival (empty if to Furizon)
|
||||
<input type="text" id="to_location" name="to_location" value="{{order.carpooling_message.to_location}}" placeholder="Furizon, Cavalese">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
|
@ -61,7 +62,7 @@
|
|||
{% endif %}
|
||||
{% for o in orders %}
|
||||
<blockquote>
|
||||
<p style="margin-bottom:1em;"><strong>{{o.name}}</strong> {{'is offering' if o.carpooling_message.offer_or_need == 'offer' else 'needs'}} a trip from <strong>{{o.carpooling_message.from_location}}</strong> on the <strong>{{o.carpooling_message.day_departure[1:]}} of {{'May' if o.carpooling_message.day_departure[0] == 'm' else 'June'}}</strong>.</p>
|
||||
<p style="margin-bottom:1em;"><strong>{{o.name}}</strong> {{'is offering' if o.carpooling_message.offer_or_need == 'offer' else 'needs'}} a trip from <strong>{{o.carpooling_message.from_location}}</strong> {% if o.carpooling_message.to_location %}to <strong>{{o.carpooling_message.to_location}}</strong>{% endif %} on the <strong>{{o.carpooling_message.day_departure[1:]}} of {{'May' if o.carpooling_message.day_departure[0] == 'm' else 'June'}}</strong>.</p>
|
||||
<img class="propic propic-{{o.sponsorship}}" style="margin-top:0.5em;margin-right:1em;float:left;max-width:4em;" src="/res/propic/{{o.ans('propic') or 'default.png'}}" />
|
||||
<span style="font-size:.8em;">{{o.carpooling_message.message|escape|replace("\n", "<br />"|safe)}}</span>
|
||||
<br clear="both" />
|
||||
|
|
Loading…
Reference in New Issue