Skip to content

Commit

Permalink
implement unsetting is_default_for on a route
Browse files Browse the repository at this point in the history
  • Loading branch information
Changaco committed Sep 30, 2024
1 parent fcbf14d commit 5466db7
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions www/%username/routes/index.spt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ if request.method == 'POST':
try:
route_id, currency = request.body['set_as_default_for'].split(':')
route_id = int(route_id)
if currency not in constants.CURRENCIES:
if currency == '':
currency = None
elif currency not in constants.CURRENCIES:
raise ValueError(currency)
except ValueError:
raise response.invalid_input(request.body['set_as_default_for'], 'set_as_default_for', 'body')
Expand Down Expand Up @@ -184,7 +186,16 @@ title = _("Payment Instruments")
% if route.network == 'stripe-card' and not route.is_default
<button class="btn btn-primary btn-xs" name="set_as_default" value="{{ route.id }}">{{ _("Set as default") }}</button>
% endif
% if last_payin and participant.donates_in_multiple_currencies and not route.is_default_for
% if route.is_default_for
<button class="btn btn-warning btn-xs"
name="set_as_default_for" value="{{ route.id }}:"
title="{{ _(
'Stop using this instrument by default for payments in {currency}.',
currency=Currency(last_payin.amount.currency)
) }}">{{ _(
"Unset as default for {currency}", currency=last_payin.amount.currency
) }}</button>
% elif route.network != 'stripe-card' and last_payin and participant.donates_in_multiple_currencies
<button class="btn btn-primary btn-xs"
name="set_as_default_for" value="{{ route.id }}:{{ last_payin.amount.currency }}"
title="{{ _(
Expand Down

0 comments on commit 5466db7

Please sign in to comment.