diagnostics: Show app name and fallback to app id if not exist

Tests performed:
- The diagnostics app page and individual app diagnostics pages have
app names.
- When the app name is missing (the apache app), app id is shown instead.

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
Veiko Aasa 2020-12-13 21:15:47 +02:00 committed by Sunil Mohan Adapa
parent 8775137546
commit dd6a03442e
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
3 changed files with 4 additions and 3 deletions

View File

@ -112,7 +112,7 @@ def run_on_all_enabled_modules():
continue continue
apps.append((app.app_id, app)) apps.append((app.app_id, app))
app_name = app.info.name or _('None') app_name = app.info.name or app.app_id
current_results['results'][app.app_id] = {'name': app_name} current_results['results'][app.app_id] = {'name': app_name}
current_results['apps'] = apps current_results['apps'] = apps

View File

@ -9,7 +9,7 @@
<h2>{% trans "Diagnostic Results" %}</h2> <h2>{% trans "Diagnostic Results" %}</h2>
<h3>{% blocktrans %}App: {{ app_id }}{% endblocktrans %}</h3> <h3>{% blocktrans %}App: {{ app_name }}{% endblocktrans %}</h3>
{% if results %} {% if results %}
{% include "diagnostics_results.html" with results=results %} {% include "diagnostics_results.html" with results=results %}

View File

@ -38,6 +38,7 @@ def diagnose_app(request, app_id):
app = App.get(app_id) app = App.get(app_id)
except KeyError: except KeyError:
raise Http404('App does not exist') raise Http404('App does not exist')
app_name = app.info.name or app_id
diagnosis = None diagnosis = None
diagnosis_exception = None diagnosis_exception = None
@ -51,7 +52,7 @@ def diagnose_app(request, app_id):
return TemplateResponse( return TemplateResponse(
request, 'diagnostics_app.html', { request, 'diagnostics_app.html', {
'title': _('Diagnostic Test'), 'title': _('Diagnostic Test'),
'app_id': app_id, 'app_name': app_name,
'results': diagnosis, 'results': diagnosis,
'exception': diagnosis_exception, 'exception': diagnosis_exception,
}) })