Skip to content

Commit

Permalink
Merge pull request #2529 from liberapay/various
Browse files Browse the repository at this point in the history
  • Loading branch information
Changaco authored Feb 6, 2025
2 parents 1ddbb6e + 6052bdf commit 38e3f29
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 31 deletions.
9 changes: 0 additions & 9 deletions liberapay/models/exchange_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,12 +422,3 @@ def stripe_payment_method(self):
@cached_property
def stripe_source(self):
return stripe.Source.retrieve(self.address)

def sync_status(self):
if self.address.startswith('pm_'):
# A PaymentMethod doesn't have a status.
return
else:
source = stripe.Source.retrieve(self.address)
self.update_status(source.status)
self.stripe_source = source
4 changes: 3 additions & 1 deletion liberapay/models/participant.py
Original file line number Diff line number Diff line change
Expand Up @@ -2187,12 +2187,14 @@ def is_char_forbidden(char):
raise ValueContainsForbiddenCharacters(new_public_name, bad_chars)

if new_public_name != self.public_name:
if new_public_name == '':
new_public_name = None
with self.db.get_cursor(cursor) as c:
r = c.one("""
UPDATE participants
SET public_name = %s
WHERE id = %s
AND (public_name IS NULL OR public_name <> %s)
AND coalesce(public_name, '') <> coalesce(%s, '')
RETURNING id
""", (new_public_name, self.id, new_public_name))
if r:
Expand Down
1 change: 0 additions & 1 deletion liberapay/payin/cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@ def execute_scheduled_payins():
scheduled_payins[:] = [Object(**sp) for sp in scheduled_payins]
for sp in scheduled_payins:
sp.route = db.ExchangeRoute.from_id(payer, sp.route)
sp.route.sync_status()
if sp.route.status != 'chargeable':
retry = True
scheduled_payins.remove(sp)
Expand Down
3 changes: 3 additions & 0 deletions sql/branch.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT 'after deployment';

UPDATE participants SET public_name = null WHERE public_name = '';
2 changes: 0 additions & 2 deletions www/%username/edit/avatar.spt
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,12 @@ subhead = _("Avatar")
<span>{{ _("What is Libravatar?") }}</span>
</a>
<br><br>
% if participant.avatar_url and request.method == 'GET'
<form action="" method="POST">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}" />
<button class="btn btn-default" name="action" value="refresh">
{{ icon('refresh') }} <span>{{ _("Refresh") }}</span>
</button>
</form>
% endif
</div>
</div>
% endif
Expand Down
17 changes: 2 additions & 15 deletions www/%username/giving/pay/stripe/%payin_id.spt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ identity = payer.get_current_identity() or {}

del currency

payment_type = request.qs.get('method', 'card')
payment_type = request.qs.get_choice('method', ('card', 'sdd'), default='card')

error = None
if request.method == 'POST':
Expand Down Expand Up @@ -87,7 +87,6 @@ if request.method == 'POST':
route = ExchangeRoute.from_id(payer, body.get_int('route'), _raise=False)
if route is None:
raise response.invalid_input(body.get('route'), 'route', 'body')
route.sync_status()
if not route.one_off:
if body.parse_boolean('set_as_default', default=False):
route.set_as_default()
Expand Down Expand Up @@ -210,19 +209,7 @@ if tippees:
, r.is_default DESC NULLS LAST
, r.network = 'stripe-sdd' DESC
, r.id DESC
""", (payer.id, 'stripe-' + (payment_type or '%'), payment.currency))
if routes:
route = None
while routes:
route = routes[0]
route.sync_status()
if route:
break
routes = routes[1:]
payment_type = route.network.split('-', 1)[-1]
del route
if not payment_type:
response.redirect(payer.path('giving/pay'))
""", (payer.id, 'stripe-' + payment_type, payment.currency))
ask_for_postal_address = (
payment_type == 'sdd' or
len(tips) == 1 and
Expand Down
2 changes: 1 addition & 1 deletion www/admin/payments.spt
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ title = "Payments Admin"
<td><a href="/~{{ pi.payer }}/">{{ pi.payer_name }}</a>{% if pi.payer_identity %}<br>
% set payer_identity = pi.payer_identity.decrypt()
<span class="break-word-anywhere monospace">
{{- payer_identity.name }}<br>
{{- payer_identity.name|default('') }}<br>
{{- render_postal_address(
payer_identity.postal_address, single_line=True, format='downward'
) -}}
Expand Down
37 changes: 35 additions & 2 deletions www/admin/users.spt
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ if mode == 'all':
ORDER BY r.network
) r
) AS payment_instruments
, ( SELECT json_objectagg(pi.status:pi.count)
FROM ( SELECT pi.status
, count(*) AS count
FROM payins pi
WHERE pi.payer = p.id
GROUP BY pi.status
ORDER BY pi.status
) pi
) AS payin_counts
, ( SELECT json_agg(json_build_object(
'provider', a.provider,
'id', a.id,
Expand Down Expand Up @@ -336,6 +345,14 @@ title = "Users Admin"
icon('search', "Look it up")
}}</button>
</form>
&nbsp;
<a href="/admin/email-domains?domain={{ row.email.address.rsplit('@', 1)[1] }}"
target="_blank" rel="noopener noreferrer" title="Look up the domain">@</a>
&nbsp;
<a href="https://verifymail.io/domain/{{ row.email.address.rsplit('@', 1)[1] }}"
target="_blank" rel="noopener noreferrer">{{
icon('external-link', "Check the domain")
}}</a>
% else
<strong>Email address:</strong> none.
% endif
Expand All @@ -352,7 +369,10 @@ title = "Users Admin"
<br>
% endfor
% else
none. <span class="text-warning">{{ icon('warning-sign') }}</span>
none.
% if row.payment_accounts
<span class="text-warning">{{ icon('warning-sign') }}</span>
% endif
% endif
</p>
% endif
Expand Down Expand Up @@ -381,6 +401,16 @@ title = "Users Admin"
none.
% endif
% endif

<p><strong>Payment attempts:</strong>
% if row.payin_counts
% for status, count in row.payin_counts.items()
{{ count }} {{ status }}{{ '.' if loop.last else ',' }}
% endfor
% else
none.
% endif
</p>
% endif

<p><strong>Payment accounts:</strong>
Expand Down Expand Up @@ -471,7 +501,10 @@ title = "Users Admin"
<br>
% endfor
% elif not p.public_name
none. <span class="text-warning">{{ icon('warning-sign') }}</span>
none.
% if row.payment_accounts
<span class="text-warning">{{ icon('warning-sign') }}</span>
% endif
% endif
</div>

Expand Down

0 comments on commit 38e3f29

Please sign in to comment.