Skip to content
Merged

Various #2723

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 41 additions & 49 deletions error.spt
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,29 @@ if not msg:
if isinstance(response, LazyResponse):
response.render_body(state)
err = response.text
if code == 500 and not err:
err = _("Looks like you've found a bug! Sorry for the inconvenience, we'll get it fixed ASAP!")
if not err:
if code == 404:
err = _("The requested page couldn't be found.")
elif code == 500:
err = _("Looks like you've found a bug! Sorry for the inconvenience. We'll fix this error as soon as possible.")
else:
err = _("An unspecified error occured. This isn't supposed to happen. Sorry.")

referer = request.headers.get(b'Referer')
user_agent = request.headers.get(b'User-Agent')
debugging_info = None if sentry_ident else f"""\
URL: {website.canonical_scheme}://{request.hostname}{request.line.uri.decoded}
Method: {request.method}
Referer: {request.headers.get(b'Referer')!r}
User-Agent: {request.headers.get(b'User-Agent')!r}
Cookies: {render_cookies(request)}
IP address: {request.source} ({request.source_country})
Time: {utcnow()}
Response code: {code}
Response message: {err!r}
User: {user}
Locale: {locale}
Website version: {website.version}
Traceback:{get_short_traceback(response.__cause__ or response)}
"""

[----------------------------------------] text/html
% extends "templates/layouts/base.html"
Expand All @@ -66,62 +84,36 @@ user_agent = request.headers.get(b'User-Agent')
% if response.html_template is defined
% include response.html_template
% else
% if code >= 400 and code <= 499
% if code == 404
<p>{{ _(
"The requested page could not be found. Please "
"{link_start}contact us{link_end} if you need assistance.",
link_start='<a href="https://liberapay.com/about/contact">'|safe,
link_end='</a>'|safe,
) }}</p>
% else
<p>{{ _(
"Your request has been rejected by our software. Please "
"{link_start}contact us{link_end} if you need assistance.",
link_start='<a href="https://liberapay.com/about/contact">'|safe,
link_end='</a>'|safe,
) }}</p>
% endif
% endif

% if err
% if '\n' in err
<pre>{{ err }}</pre>
% else
<p>{{ _("Error message:") }}</p>
<div class="alert alert-danger">{{ err }}</div>
% endif
% if '\n' in err
<pre class="alert alert-danger">{{ err }}</pre>
% else
<div class="alert alert-danger">{{ err }}</div>
% endif

% if sentry_ident
<p>{{ _(
"The details of this error have been recorded. If you decide to contact us, "
"please include the following error identification code in your message: {0}.",
'<code>%s</code>'|safe % sentry_ident
"The details of this error have been recorded. If you decide to "
"{link_start}contact us{link_end}, please include the following "
"error identification code in your message: {0}.",
'<code>%s</code>'|safe % sentry_ident,
link_start='<a href="/about/contact" target="_blank">'|safe,
link_end='</a>'|safe,
) }}</p>
% else
<br>
<p>{{ _("If you decide to contact us please include the following debugging information in your message:") }}</p>
<pre>URL: {{ website.canonical_scheme }}://{{ request.hostname }}{{ request.line.uri.decoded }}{{ '\n'
}}Method: {{ request.method }}{{ '\n'
}}Referer: {{ repr(referer) }}{{ '\n'
}}User-Agent: {{ repr(user_agent) }}{{ '\n'
}}Cookies: {{ render_cookies(request) }}{{ '\n'
}}IP address: {{ request.source }} ({{ request.source_country }}){{ '\n'
}}Time: {{ utcnow() }}{{ '\n'
}}Response code: {{ code }}{{ '\n'
}}Response message: {{ repr(err) }}{{ '\n'
}}User: {{ user }}{{ '\n'
}}Locale: {{ locale }}{{ '\n'
}}Website version: {{ website.version }}{{ '\n'
}}Traceback:{{
get_short_traceback(response.__cause__ or response)
}}</pre>
<p>{{ _(
"If you decide to {link_start}contact us{link_end} about this "
"issue, please include the following debugging information in "
"your message:",
link_start='<a href="/about/contact" target="_blank">'|safe,
link_end='</a>'|safe,
) }}</p>
<pre>{{ debugging_info }}</pre>
% endif
% endif
% endblock
[----------------------------------------] application/json via json_dump
{
"debugging_info": debugging_info,
"error_code": code,
"error_id": sentry_ident,
"error_message_long": err,
Expand Down
5 changes: 5 additions & 0 deletions style/base/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ p.summary {
display: flex;
justify-content: space-around;
margin: $line-height-computed 0 0;
min-height: 66px;
& > dl {
margin: 0 10px 0 0;
& > dt {
Expand All @@ -259,6 +260,10 @@ p.summary {
color: $gray-light;
font-size: $font-size-small;
}
& > i {
color: $gray-light;
font-size: $font-size-base;
}
}
}
}
Expand Down
13 changes: 9 additions & 4 deletions templates/log-in-form.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,22 @@
% set email = state['log-in.email-sent-to']
<div class="alert alert-success">
<p>{{ _(
"We've sent you a single-use login link. Check your inbox, open the "
"provided link in a new tab, then come back to this page and click on "
"the button below to carry on with what you wanted to do."
"A single-use authentication link has been emailed to {email_address}.",
email_address='<code>%s</code>'|safe % email
) }}</p>
<p>{{ _("Check your inbox, and perhaps your spam folder.") }}</p>
% if not request.body.parse_boolean('log-in.close-tab', False)
<p>{{ _(
"Open the authentication link in a new tab, then come back to this page "
"and click on the button below to carry on with what you wanted to do."
) }}</p>

<br>
<form action="" method="POST">
% include "templates/form-repost.html"
<input type="hidden" name="log-in.carry-on" value="{{ email }}" />
<button class="btn btn-success">{{ _("Carry on") }}</button>
</form>
% endif
</div>

% elif state.get('log-in.carry-on')
Expand Down
16 changes: 15 additions & 1 deletion templates/macros/auth.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ <h3>{{ _("Password") }}</h3>
"the password should be randomly generated and not used anywhere else."
) }}</p>
% endif
% set require_current_password = participant.has_password and user.session_type not in ('em', 'in')
<form action="{{ participant.path('settings/edit') }}" method="POST" class="form-inline buttons">
<input name="csrf_token" type="hidden" value="{{ csrf_token }}" />
<input name="back_to" type="hidden" value="{{ participant.path('settings/') }}" />
<input name="email" value="{{ participant.get_email_address() or '' }}"
aria-hidden="true" class="out-of-sight" tabindex="-1" />
% if participant.has_password and user.session_type != 'em'
% if require_current_password
<div class="form-group">
<input type="password" name="cur-password" class="form-control"
placeholder="{{ _('Current password') }}" />
Expand All @@ -39,6 +40,19 @@ <h3>{{ _("Password") }}</h3>
% endif
</form>
<p class="help-block">{{ _("Maximum length is {0}.", constants.PASSWORD_MAX_SIZE) }}</p>
% if require_current_password
<form action="" method="POST">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}" />
<input type="hidden" name="log-in.id" value="{{ participant.get_email_address() }}" />
<input type="hidden" name="log-in.close-tab" value="yes" />
<p>{{ _(
"If you've {bold}lost your current password{bold_end}, you have to "
"log in via email to be able to replace it:",
bold='<strong>'|safe, bold_end='</strong>'|safe,
) }}</p>
<button class="btn btn-default">{{ _("Log in via email") }}</button>
</form>
% endif

<h3>{{ _("2FA") }}</h3>
<p>{{ _("Liberapay does not yet support two-factor authentication.") }}</p>
Expand Down
6 changes: 4 additions & 2 deletions templates/macros/profile-box.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ <h4><a href="/{{ username }}/">{{ username }}</a></h4>
<dt>{{ _("Patrons") }}</dt>
<dd>{{ locale.format_decimal(participant.npatrons + participant.nteampatrons) }}</dd>
</dl>
% if not participant.hide_receiving
<dl>
<dt>{{ _("Income") }}</dt>
% if participant.hide_receiving
<dd><i>{{ _("undisclosed") }}</i></dd>
% else
<dd>{{ locale.format_money(participant.receiving) }}<br>
<small>{{ _("per week") }}</small></dd>
% endif
</dl>
% endif
% if nmembers
<dl>
<dt>{{ _("Members") }}</dt>
Expand Down
6 changes: 3 additions & 3 deletions tests/py/test_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def test_payment_instruments_page(self):
assert r.code == 403, r.text
r = self.client.GET('/alice/routes/', auth_as=alice)
assert r.code == 200, r.text
assert "You don&#39;t have any valid payment instrument." in r.text, r.text
assert "No valid payment instruments are attached" in r.text, r.text
r = self.client.GET('/alice/routes/add?type=stripe-card', auth_as=alice)
assert r.code == 200, r.text
r = self.client.POST(
Expand All @@ -202,7 +202,7 @@ def test_payment_instruments_page(self):
assert r.code == 302, r.text
r = self.client.GET('/alice/routes/', auth_as=alice)
assert r.code == 200, r.text
assert "You have 1 connected payment instrument." in r.text, r.text
assert "1 valid payment instrument is attached" in r.text, r.text
sepa_debit_pm = stripe.PaymentMethod.create(
type='sepa_debit',
billing_details=dict(
Expand All @@ -221,7 +221,7 @@ def test_payment_instruments_page(self):
assert r.code == 302, r.text
r = self.client.GET('/alice/routes/', auth_as=alice)
assert r.code == 200, r.text
assert "You have 2 connected payment instruments." in r.text, r.text
assert "2 valid payment instruments are attached" in r.text, r.text
r = self.client.POST(
'/alice/routes/',
{'set_as_default': str(offset + 1)},
Expand Down
19 changes: 14 additions & 5 deletions www/%username/routes/index.spt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ if request.method == 'POST':
raise response.error(400, "no known action found in request body")
form_post_success(state)

show_invalid_instruments = user.is_acting_as('admin')
routes = website.db.all("""
SELECT r
, ( SELECT pi
Expand All @@ -51,7 +52,7 @@ routes = website.db.all("""
AND r.network IN ('stripe-card', 'stripe-sdd')
AND ( r.status IN ('chargeable', 'pending') OR %s )
ORDER BY r.ctime DESC
""", (participant.id, user.is_acting_as('admin')))
""", (participant.id, show_invalid_instruments))

today = utcnow().date()

Expand Down Expand Up @@ -85,7 +86,7 @@ title = _("Payment Instruments")
) }}
&nbsp;
<a class="btn btn-primary" href="{{ participant.path('giving/pay') }}">{{
ngettext("Renew this donation", "Renew these donations", ntips_awaiting_payment)
ngettext("Fund your donation", "Fund your donations", ntips_awaiting_payment)
}}</a>
</div>
% endif
Expand All @@ -94,8 +95,12 @@ title = _("Payment Instruments")
% endif

<p>{{ ngettext(
"You have {n} connected payment instrument.",
"You have {n} connected payment instruments.",
"{n} payment instrument is attached to this account.",
"{n} payment instruments are attached to this account.",
n=len(routes)
) if show_invalid_instruments else ngettext(
"{n} valid payment instrument is attached to this account.",
"{n} valid payment instruments are attached to this account.",
n=len(routes)
) }}</p>
<form action="" method="POST">
Expand Down Expand Up @@ -222,7 +227,11 @@ title = _("Payment Instruments")
% endfor
</form>
% else
<p>{{ _("You don't have any valid payment instrument.") }}</p>
<p>{{ _(
"No payment instruments are attached to this account."
) if show_invalid_instruments else _(
"No valid payment instruments are attached to this account."
) }}</p>
% endif

<br>
Expand Down
15 changes: 10 additions & 5 deletions www/about/contact.spt
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,23 @@ title = _("Contact")
% block content

<p class="text-warning">{{ icon('warning-sign') }} {{ _(
"Do not contact us if you are trying to reach one of our users. We do not "
"relay messages, and we cannot reveal the identity or contact details of "
"our users unless you have a valid court order."
"If you're trying to reach the owner of a Liberapay account, be advised "
"that we generally don't relay messages and can't reveal the identity or "
"contact details of our users."
) }}</p>

<br>
<h4>{{ _("To contact the Liberapay team privately:") }}</h4>
<h4>{{ _("To contact a Liberapay maintainer privately:") }}</h4>
<p><a class="btn btn-primary" data-email="support&#64;liberapay.com">{{
_("Send an email to Liberapay")
}}</a></p>
<p>{{ _(
"If your message isn't written in English or French, then it will be translated "
"We're very busy, so you shouldn't expect a fast response. Some messages "
"may not be answered at all, especially if they're disrespectful, "
"rambling or misdirected."
) }}</p>
<p>{{ _(
"If your message isn't written in English or French, it will be translated "
"automatically by a machine. Our reply will be translated to your language "
"the same way."
) }}</p>
Expand Down
Loading