mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-08-19 12:36:06 +00:00
help: Make about page available to unauthenticated users
- This page will replace the rather large footer in the front page. Tests: - Log out. Visit the help about page. It is available without redirection to login page. Version related alert is not shown. - Log in. Visit the help about page. It is available. Version related alert is shown. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
5db6c46e8b
commit
62e67c6c99
@ -13,23 +13,25 @@
|
||||
class="main-graphic" />
|
||||
</p>
|
||||
|
||||
<div class="alert {% if new_version %}alert-warning{% else %}alert-success{% endif %}">
|
||||
{% blocktrans trimmed %}
|
||||
You are running {{ os_release }} and {{ box_name }} version {{ version }}.
|
||||
{% endblocktrans %}
|
||||
{% if version %}
|
||||
<div class="alert {% if new_version %}alert-warning{% else %}alert-success{% endif %}">
|
||||
{% 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
|
||||
<a href="{{ upgrades_url }}">available</a>.
|
||||
{% endblocktrans %}
|
||||
{% else %}
|
||||
{% blocktrans trimmed %}
|
||||
{{ box_name }} is up to date.
|
||||
{% endblocktrans %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if new_version %}
|
||||
{% url 'upgrades:index' as upgrades_url %}
|
||||
{% blocktrans trimmed %}
|
||||
There is a new {{ box_name }} version
|
||||
<a href="{{ upgrades_url }}">available</a>.
|
||||
{% endblocktrans %}
|
||||
{% else %}
|
||||
{% blocktrans trimmed %}
|
||||
{{ box_name }} is up to date.
|
||||
{% endblocktrans %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<p>
|
||||
{% blocktrans trimmed %}
|
||||
|
||||
@ -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")
|
||||
|
||||
@ -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'),
|
||||
|
||||
@ -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)
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user