Fixes to carpooling function

This commit is contained in:
Ed 2023-05-08 23:42:18 +02:00
parent 2265778eb9
commit 0c3e80320e
2 changed files with 5 additions and 5 deletions

View File

@ -36,13 +36,13 @@ async def carpooling_update(request, order: Order):
error = "Offer or need form is not valid!" error = "Offer or need form is not valid!"
elif len(val) > 1000 and field == 'message': elif len(val) > 1000 and field == 'message':
error = "The message cannot be longer than 1000 characters!" error = "The message cannot be longer than 1000 characters!"
elif val.count("\n") > 4: elif val.count("\n") > 6:
error = "Please do not use more than 4 line breaks!" error = "Please do not use more than 6 line breaks in the message!"
else: else:
payload[field] = val payload[field] = val
order.carpooling_message = payload
if not error: if not error:
order.carpooling_message = payload
await order.edit_answer('carpooling_message', json.dumps(payload)) await order.edit_answer('carpooling_message', json.dumps(payload))
else: else:

View File

@ -34,7 +34,7 @@
<label for="offer_or_need">Are you offering or need a ride?</label> <label for="offer_or_need">Are you offering or need a ride?</label>
<select name="offer_or_need" id="offer_or_need"> <select name="offer_or_need" id="offer_or_need">
<option value="need" {{'selected' if order.carpooling_message.offer_or_need == 'need'}}>I'm looking for a ride</option> <option value="need" {{'selected' if order.carpooling_message.offer_or_need == 'need'}}>I'm looking for a ride</option>
<option value="offer" {{'selected' if order.carpooling_message.offer_or_need == 'need'}}>I'm offering a ride</option> <option value="offer" {{'selected' if order.carpooling_message.offer_or_need == 'offer'}}>I'm offering a ride</option>
</select> </select>
<label for="day_departure"> <label for="day_departure">
@ -63,7 +63,7 @@
<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> 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}}</span> <span style="font-size:.8em;">{{o.carpooling_message.message|escape|replace("\n", "<br />"|safe)}}</span>
<br clear="both" /> <br clear="both" />
</blockquote> </blockquote>
{% endfor %} {% endfor %}