cockpit: add list of valid urls to access the app.

Closes #1649

Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Nektarios Katakis 2019-12-10 13:54:26 +00:00 committed by James Valleroy
parent 656988cc54
commit 4805e01929
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
4 changed files with 89 additions and 9 deletions

View File

@ -44,6 +44,8 @@ managed_packages = ['cockpit']
name = _('Cockpit')
icon_filename = 'cockpit'
short_description = _('Server Administration')
description = [

View File

@ -0,0 +1,39 @@
{% extends "app.html" %}
{% comment %}
#
# This file is part of FreedomBox.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
{% endcomment %}
{% load bootstrap %}
{% load i18n %}
{% block status %}
{{ block.super }}
<h3>{% trans "Access" %}</h3>
<p>
{% blocktrans trimmed %}
Cockpit will only work when accessed using the following URLs.
{% endblocktrans %}
</p>
<ol>
{% for url_ in urls %}
<li>{{ url_ }}</li>
{% endfor %}
</ol>
{% endblock %}

View File

@ -20,15 +20,8 @@ URLs for Cockpit module.
from django.conf.urls import url
from plinth.modules import cockpit
from plinth.views import AppView
from plinth.modules.cockpit.views import CockpitAppView
urlpatterns = [
url(
r'^sys/cockpit/$',
AppView.as_view(app_id='cockpit', name=cockpit.name,
diagnostics_module_name='cockpit',
description=cockpit.description,
show_status_block=True, clients=cockpit.clients,
manual_page=cockpit.manual_page), name='index'),
url(r'^sys/cockpit/$', CockpitAppView.as_view(), name='index'),
]

View File

@ -0,0 +1,46 @@
#
# This file is part of FreedomBox.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
Views for the Cockpit module
"""
from plinth.views import AppView
from plinth.modules.cockpit import (
name,
description,
clients,
manual_page,
icon_filename,
)
from plinth.modules.cockpit.utils import get_origin_domains, load_augeas
class CockpitAppView(AppView):
app_id = 'cockpit'
name = name
description = description
diagnostics_module_name = 'cockpit'
show_status_block = True
clients = clients
manual_page = manual_page
template_name = 'cockpit.html'
icon_filename = icon_filename
def get_context_data(self, *args, **kwargs):
context = super().get_context_data(**kwargs)
context['urls'] = get_origin_domains(load_augeas())
return context