views: Don't require sending diagnostics module name separately

- Reuse the app_id already available to the view.

- Implement automatically detecting if an app has implemented diagnostics.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2019-12-17 15:54:16 -08:00 committed by James Valleroy
parent 636aa05b66
commit f65b4ec407
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
36 changed files with 12 additions and 39 deletions

View File

@ -31,7 +31,6 @@ from .forms import BindForm
class BindAppView(AppView): # pylint: disable=too-many-ancestors
"""A specialized view for configuring Bind."""
app_id = 'bind'
diagnostics_module_name = 'bind'
name = name
description = description
show_status_block = True

View File

@ -27,7 +27,6 @@ class CockpitAppView(AppView):
app_id = 'cockpit'
name = name
description = description
diagnostics_module_name = 'cockpit'
show_status_block = True
clients = clients
manual_page = manual_page

View File

@ -35,7 +35,6 @@ class CoquelicotAppView(views.AppView):
clients = clients
name = name
description = description
diagnostics_module_name = 'coquelicot'
app_id = 'coquelicot'
form_class = CoquelicotForm
show_status_block = True

View File

@ -37,7 +37,6 @@ class DateTimeAppView(AppView):
description = datetime.description
form_class = DateTimeForm
app_id = 'datetime'
diagnostics_module_name = 'datetime'
manual_page = datetime.manual_page
def get_initial(self):

View File

@ -27,7 +27,6 @@ urlpatterns = [
url(
r'^apps/deluge/$',
AppView.as_view(name=deluge.name, description=deluge.description,
diagnostics_module_name='deluge',
clients=deluge.clients, app_id='deluge',
manual_page=deluge.manual_page,
icon_filename=deluge.icon_filename), name='index'),

View File

@ -60,7 +60,6 @@ class DiasporaAppView(AppView):
form_class = DiasporaAppForm
app_id = 'diaspora'
template_name = 'diaspora-post-setup.html'
diagnostics_module_name = 'diaspora'
name = diaspora.name
def dispatch(self, request, *args, **kwargs):

View File

@ -34,7 +34,6 @@ class EjabberdAppView(AppView):
template_name = 'ejabberd.html'
name = ejabberd.name
description = ejabberd.description
diagnostics_module_name = 'ejabberd'
form_class = EjabberdForm
manual_page = ejabberd.manual_page
port_forwarding_info = ejabberd.port_forwarding_info

View File

@ -40,7 +40,6 @@ class GitwebAppView(views.AppView):
clients = gitweb.clients
name = gitweb.name
description = gitweb.description
diagnostics_module_name = 'gitweb'
app_id = 'gitweb'
show_status_block = False
template_name = 'gitweb_configure.html'

View File

@ -44,7 +44,6 @@ class I2PAppView(AppView):
clients = i2p.clients
name = i2p.name
description = i2p.description
diagnostics_module_name = i2p.service_name
show_status_block = True
template_name = 'i2p.html'
icon_filename = i2p.icon_filename

View File

@ -35,7 +35,6 @@ class IkiwikiAppView(views.AppView):
app_id = 'ikiwiki'
name = ikiwiki.name
description = ikiwiki.description
diagnostics_module_name = 'ikiwiki'
show_status_block = False
template_name = 'ikiwiki_configure.html'
manual_page = ikiwiki.manual_page

View File

@ -102,7 +102,6 @@ def init():
class InfinotedAppView(AppView):
app_id = 'infinoted'
diagnostics_module_name = 'infinoted'
name = name
description = description
clients = clients

View File

@ -38,11 +38,12 @@ def index(request):
status = letsencrypt.get_status()
return TemplateResponse(
request, 'letsencrypt.html', {
'app_id': 'letsencrypt',
'name': letsencrypt.name,
'description': letsencrypt.description,
'status': status,
'manual_page': letsencrypt.manual_page,
'diagnostics_module_name': 'letsencrypt',
'has_diagnostics': True,
'is_enabled': letsencrypt.app.is_enabled(),
})

View File

@ -65,7 +65,6 @@ class MatrixSynapseAppView(AppView):
template_name = 'matrix-synapse.html'
name = matrixsynapse.name
description = matrixsynapse.description
diagnostics_module_name = 'matrixsynapse'
form_class = MatrixSynapseForm
port_forwarding_info = matrixsynapse.port_forwarding_info
icon_filename = matrixsynapse.icon_filename

View File

@ -37,7 +37,6 @@ class MediaWikiAppView(views.AppView):
clients = mediawiki.clients
name = mediawiki.name
description = mediawiki.description
diagnostics_module_name = 'mediawiki'
app_id = 'mediawiki'
form_class = MediaWikiForm
manual_page = mediawiki.manual_page

View File

@ -32,7 +32,6 @@ from .forms import MinetestForm
class MinetestAppView(AppView): # pylint: disable=too-many-ancestors
"""A specialized view for configuring minetest."""
app_id = 'minetest'
diagnostics_module_name = 'minetest'
name = minetest.name
description = description
show_status_block = True

View File

@ -34,7 +34,6 @@ class MiniDLNAAppView(AppView):
name = minidlna.name
description = minidlna.description
form_class = MiniDLNAServerForm
diagnostics_module_name = 'minidlna'
icon_filename = minidlna.icon_filename
def get_initial(self):

View File

@ -27,7 +27,6 @@ urlpatterns = [
url(
r'^apps/mldonkey/$',
AppView.as_view(app_id='mldonkey', name=mldonkey.name,
diagnostics_module_name='mldonkey',
description=mldonkey.description,
clients=mldonkey.clients,
manual_page=mldonkey.manual_page,

View File

@ -26,7 +26,6 @@ from plinth.views import AppView
class MumbleAppView(AppView):
app_id = 'mumble'
diagnostics_module_name = 'mumble'
name = name
description = description
clients = clients

View File

@ -39,11 +39,12 @@ def index(request):
return TemplateResponse(
request, 'connections_list.html', {
'app_id': 'networks',
'title': _('Network Connections'),
'name': networks.name,
'description': networks.description,
'manual_page': networks.manual_page,
'diagnostics_module_name': 'networks',
'has_diagnostics': True,
'is_enabled': True,
'connections': connections
})

View File

@ -58,6 +58,7 @@ def index(request):
return TemplateResponse(
request, 'openvpn.html', {
'app_id': 'openvpn',
'clients': openvpn.clients,
'name': openvpn.name,
'description': openvpn.description,
@ -67,7 +68,7 @@ def index(request):
'form': form,
'show_status_block': True,
'is_running': status['is_running'],
'diagnostics_module_name': 'openvpn',
'has_diagnostics': True,
'is_enabled': status['enabled'],
'icon_filename': openvpn.icon_filename
})

View File

@ -122,7 +122,6 @@ def setup(helper, old_version=None):
class PrivoxyAppView(AppView):
app_id = 'privoxy'
diagnostics_module_name = 'privoxy'
name = name
description = description
manual_page = manual_page

View File

@ -23,7 +23,6 @@ from .forms import QuasselForm
class QuasselAppView(AppView):
app_id = 'quassel'
diagnostics_module_name = 'quassel'
name = quassel.name
description = quassel.description
clients = quassel.clients

View File

@ -34,7 +34,6 @@ class RadicaleAppView(AppView):
clients = radicale.clients
name = radicale.name
description = description
diagnostics_module_name = 'radicale'
form_class = RadicaleForm
app_id = 'radicale'
manual_page = radicale.manual_page

View File

@ -122,7 +122,6 @@ class ReproAppView(AppView):
clients = clients
name = name
description = description
diagnostics_module_name = 'repro'
app_id = 'repro'
manual_page = manual_page
port_forwarding_info = port_forwarding_info

View File

@ -27,7 +27,6 @@ urlpatterns = [
url(
r'^apps/roundcube/$',
AppView.as_view(app_id='roundcube', name=roundcube.name,
diagnostics_module_name='roundcube',
description=roundcube.description,
show_status_block=False, clients=roundcube.clients,
manual_page=roundcube.manual_page,

View File

@ -39,7 +39,6 @@ class SambaAppView(views.AppView):
"""Samba sharing basic configuration."""
name = samba.name
description = samba.description
diagnostics_module_name = 'samba'
app_id = 'samba'
template_name = 'samba.html'
icon_filename = samba.icon_filename

View File

@ -33,7 +33,6 @@ class SearxAppView(views.AppView):
clients = searx.clients
name = searx.name
description = searx.description
diagnostics_module_name = 'searx'
app_id = 'searx'
form_class = SearxForm
show_status_block = False

View File

@ -33,7 +33,6 @@ from .forms import ShadowsocksForm
class ShadowsocksAppView(views.AppView):
"""Configuration view for Shadowsocks local socks5 proxy."""
app_id = 'shadowsocks'
diagnostics_module_name = 'shadowsocks'
form_class = ShadowsocksForm
name = shadowsocks.name
description = shadowsocks.description

View File

@ -27,7 +27,6 @@ urlpatterns = [
url(
r'^apps/syncthing/$',
AppView.as_view(app_id='syncthing', name=syncthing.name,
diagnostics_module_name='syncthing',
description=syncthing.description,
clients=syncthing.clients,
manual_page=syncthing.manual_page,

View File

@ -55,7 +55,6 @@ class TahoeAppView(AppView):
template_name = 'tahoe-post-setup.html'
name = tahoe.name
description = tahoe.description
diagnostics_module_name = 'tahoe'
port_forwarding_info = tahoe.port_forwarding_info
icon_filename = tahoe.icon_filename

View File

@ -52,6 +52,7 @@ def index(request):
return TemplateResponse(
request, 'tor.html', {
'app_id': 'tor',
'name': tor.name,
'description': tor.description,
'clients': tor.clients,
@ -60,7 +61,7 @@ def index(request):
'config_running': bool(config_process),
'form': form,
'firewall': tor.app.get_components_of_type(Firewall),
'diagnostics_module_name': 'tor',
'has_diagnostics': True,
'is_enabled': status['enabled'],
'show_status_block': True,
'is_running': status['is_running'],

View File

@ -39,7 +39,6 @@ class TransmissionAppView(views.AppView):
clients = transmission.clients
name = transmission.name
description = transmission.description
diagnostics_module_name = 'transmission'
form_class = TransmissionForm
app_id = 'transmission'
manual_page = transmission.manual_page

View File

@ -27,7 +27,6 @@ urlpatterns = [
url(
r'^apps/ttrss/$',
AppView.as_view(app_id='ttrss', name=ttrss.name,
diagnostics_module_name='ttrss',
description=ttrss.description, clients=ttrss.clients,
icon_filename=ttrss.icon_filename,
manual_page=ttrss.manual_page, show_status_block=True),

View File

@ -76,7 +76,6 @@ class UserList(AppView, ContextMixin, django.views.generic.ListView):
description = users.description
app_id = 'users'
show_status_block = False
diagnostics_module_name = 'users'
manual_page = users.manual_page
def get_context_data(self, *args, **kwargs):

View File

@ -50,7 +50,7 @@
{% endwith %}
{% endif %}
{% if diagnostics_module_name %}
{% if has_diagnostics %}
<!-- Single button -->
<div class="btn-group button-extra-actions">
<button type="button" class="btn btn-default dropdown-toggle"
@ -61,7 +61,7 @@
</button>
<ul class="dropdown-menu">
<li>
{% include "diagnostics_button.html" with app_id=diagnostics_module_name enabled=is_enabled %}
{% include "diagnostics_button.html" with app_id=app_id enabled=is_enabled %}
</li>
</ul>
</div>

View File

@ -112,8 +112,6 @@ class LanguageSelectionView(FormView):
class AppView(FormView):
"""A generic view for configuring simple apps."""
clients = []
# Set diagnostics_module_name to the module name to show diagnostics button
diagnostics_module_name = ""
name = None
# List of paragraphs describing the service
description = ""
@ -190,11 +188,12 @@ class AppView(FormView):
context = super().get_context_data(*args, **kwargs)
context.update(self._get_common_status())
context['app'] = self.app
context['app_id'] = self.app.app_id
context['is_running'] = app_is_running(self.app)
context['clients'] = self.clients
context['diagnostics_module_name'] = self.diagnostics_module_name
context['name'] = self.name
context['description'] = self.description
context['has_diagnostics'] = self.app.has_diagnostics()
context['show_status_block'] = self.show_status_block
context['manual_page'] = self.manual_page
context['port_forwarding_info'] = self.port_forwarding_info