diff --git a/plinth/modules/help/templates/help_about.html b/plinth/modules/help/templates/help_about.html index 5484c85a3..155fef351 100644 --- a/plinth/modules/help/templates/help_about.html +++ b/plinth/modules/help/templates/help_about.html @@ -13,23 +13,25 @@ class="main-graphic" />

-
- {% blocktrans trimmed %} - You are running {{ os_release }} and {{ box_name }} version {{ version }}. - {% endblocktrans %} + {% if version %} +
+ {% blocktrans trimmed %} + You are running {{ os_release }} and {{ box_name }} version {{ version }}. + {% endblocktrans %} - {% if new_version %} - {% url 'upgrades:index' as upgrades_url %} - {% blocktrans trimmed %} - There is a new {{ box_name }} version - available. - {% endblocktrans %} - {% else %} - {% blocktrans trimmed %} - {{ box_name }} is up to date. - {% endblocktrans %} - {% endif %} -
+ {% if new_version %} + {% url 'upgrades:index' as upgrades_url %} + {% blocktrans trimmed %} + There is a new {{ box_name }} version + available. + {% endblocktrans %} + {% else %} + {% blocktrans trimmed %} + {{ box_name }} is up to date. + {% endblocktrans %} + {% endif %} +
+ {% endif %}

{% blocktrans trimmed %} diff --git a/plinth/modules/help/tests/test_views.py b/plinth/modules/help/tests/test_views.py index 9839c4e51..6f4b7e620 100644 --- a/plinth/modules/help/tests/test_views.py +++ b/plinth/modules/help/tests/test_views.py @@ -12,7 +12,7 @@ Pending: - status log import json import pathlib import subprocess -from unittest.mock import patch +from unittest.mock import Mock, patch import pytest from django import urls @@ -113,11 +113,19 @@ def test_contribute_page(requests_get, decompress, apt_cache, rf): def test_about(_get_os_release, _is_newer_version_available, rf): """Test some expected items in about view.""" about_url = urls.reverse('help:about') - response = views.about(rf.get(about_url)) + request = rf.get(about_url) + request.user = Mock() + request.user.is_authenticated = True + response = views.about(request) assert _is_page(response) for item in ('version', 'new_version', 'os_release'): assert item in response.context_data + request.user.is_authenticated = False + response = views.about(request) + for item in ('version', 'new_version', 'os_release'): + assert item not in response.context_data + # --------------------------------------------------------------------------- # Tests for serving the offline user guide ( the "manual") diff --git a/plinth/modules/help/urls.py b/plinth/modules/help/urls.py index 188cbf07d..4f91d1d6f 100644 --- a/plinth/modules/help/urls.py +++ b/plinth/modules/help/urls.py @@ -4,6 +4,7 @@ URLs for the Help module """ from django.urls import re_path +from stronghold.decorators import public from plinth.utils import non_admin_view @@ -11,7 +12,7 @@ from . import views urlpatterns = [ re_path(r'^help/$', non_admin_view(views.index), name='index'), - re_path(r'^help/about/$', non_admin_view(views.about), name='about'), + re_path(r'^help/about/$', public(views.about), name='about'), re_path(r'^help/feedback/$', non_admin_view(views.feedback), name='feedback'), re_path(r'^help/support/$', non_admin_view(views.support), name='support'), diff --git a/plinth/modules/help/views.py b/plinth/modules/help/views.py index cabbb0bfc..a5638bc40 100644 --- a/plinth/modules/help/views.py +++ b/plinth/modules/help/views.py @@ -95,12 +95,14 @@ def support(request): def about(request): """Serve the about page""" - context = { - 'title': _('About {box_name}').format(box_name=_(cfg.box_name)), - 'version': __version__, - 'new_version': upgrades_views.is_newer_version_available(), - 'os_release': upgrades_views.get_os_release() - } + context = {'title': _('About {box_name}').format(box_name=_(cfg.box_name))} + if request.user.is_authenticated: + context.update({ + 'version': __version__, + 'new_version': upgrades_views.is_newer_version_available(), + 'os_release': upgrades_views.get_os_release() + }) + return TemplateResponse(request, 'help_about.html', context)