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 = {}
|
payload = {}
|
||||||
for field in ['from_location', 'offer_or_need', 'day_departure', 'message']:
|
for field in ['from_location', 'offer_or_need', 'day_departure', 'message']:
|
||||||
val = request.form.get(field)
|
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})"
|
error = f"One of the forms contains invalid values. ({field})"
|
||||||
elif len(val) > 64 and field != 'message':
|
elif len(val) > 64 and field != 'message':
|
||||||
error = "One of the forms contains too long values."
|
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!"
|
error = "Please do not use more than 6 line breaks in the message!"
|
||||||
else:
|
else:
|
||||||
payload[field] = val
|
payload[field] = val
|
||||||
|
|
||||||
|
if request.form.get('to_location'):
|
||||||
|
payload['to_location'] = request.form.get('to_location')
|
||||||
|
|
||||||
if not error:
|
if not error:
|
||||||
order.carpooling_message = payload
|
order.carpooling_message = payload
|
||||||
|
|
|
@ -9,12 +9,13 @@
|
||||||
</picture>
|
</picture>
|
||||||
</header>
|
</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>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">
|
<form action="" method="post">
|
||||||
{% if error %}
|
{% if error %}
|
||||||
<p class="notice">⚠️ {{error}}</p>
|
<p class="notice">⚠️ {{error}}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<section>
|
<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>
|
</section>
|
||||||
|
|
||||||
<div id="tripform" style="{{'display:none;' if not order.carpooling_message else ''}}">
|
<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>
|
<input type="text" id="from_location" name="from_location" placeholder="Example: Milan, Italy" value="{{order.carpooling_message.from_location}}" required>
|
||||||
</label>
|
</label>
|
||||||
<label for="to_location">
|
<label for="to_location">
|
||||||
Arrival
|
Arrival (empty if to Furizon)
|
||||||
<input type="text" id="to_location" name="to_location" value="Furizon, Cavalese" readonly>
|
<input type="text" id="to_location" name="to_location" value="{{order.carpooling_message.to_location}}" placeholder="Furizon, Cavalese">
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -61,7 +62,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% for o in orders %}
|
{% for o in orders %}
|
||||||
<blockquote>
|
<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'}}" />
|
<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>
|
<span style="font-size:.8em;">{{o.carpooling_message.message|escape|replace("\n", "<br />"|safe)}}</span>
|
||||||
<br clear="both" />
|
<br clear="both" />
|
||||||
|
|
Loading…
Reference in New Issue