backoffice: truncate error details in errors_block (#42744)
This commit is contained in:
parent
56b48d5457
commit
1f4ac8d124
|
@ -5755,10 +5755,15 @@ def test_backoffice_logged_errors(pub):
|
|||
resp = resp.form.submit('submit')
|
||||
assert LoggedError.count() == 2
|
||||
|
||||
app = login(get_app(pub))
|
||||
resp = app.get('/backoffice/workflows/%s/' % workflow.id)
|
||||
assert 'Failed to evaluate condition' in resp.text
|
||||
assert "error NameError (name 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx…" in resp.text
|
||||
|
||||
# remove formdef
|
||||
FormDef.wipe()
|
||||
resp = resp2.click('Failed to evaluate condition')
|
||||
assert not 'href="http://example.net/backoffice/management/test/' in resp.text
|
||||
assert 'href="http://example.net/backoffice/management/test/' not in resp.text
|
||||
|
||||
|
||||
def test_backoffice_formdata_named_wscall(http_requests, pub):
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
import re
|
||||
|
||||
from django.utils.text import Truncator
|
||||
from quixote import get_response, get_publisher, redirect
|
||||
from quixote.directory import Directory
|
||||
from quixote.html import TemplateIO, htmltext
|
||||
|
@ -180,10 +181,12 @@ class LoggedErrorsDirectory(Directory):
|
|||
for error in errors[:3]:
|
||||
r += htmltext('<li><a href="logged-errors/%s/">%s</a> ') % (error.id, error.summary)
|
||||
if error.exception_class or error.exception_message:
|
||||
r += htmltext(_('error %(class)s (%(message)s)')) % {
|
||||
message = _('error %(class)s (%(message)s)') % {
|
||||
'class': error.exception_class,
|
||||
'message': error.exception_message,
|
||||
}
|
||||
message = Truncator(message).chars(80, truncate='…')
|
||||
r += htmltext(message)
|
||||
r += htmltext('</li>')
|
||||
if len(errors) > 3:
|
||||
r += htmltext('<li>...</li>')
|
||||
|
|
Loading…
Reference in New Issue