From f65b4ec40738c59e97ba66a3cfb7ea32f481420f Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Tue, 17 Dec 2019 15:54:16 -0800 Subject: [PATCH] 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 Reviewed-by: James Valleroy --- plinth/modules/bind/views.py | 1 - plinth/modules/cockpit/views.py | 1 - plinth/modules/coquelicot/views.py | 1 - plinth/modules/datetime/views.py | 1 - plinth/modules/deluge/urls.py | 1 - plinth/modules/diaspora/views.py | 1 - plinth/modules/ejabberd/views.py | 1 - plinth/modules/gitweb/views.py | 1 - plinth/modules/i2p/views.py | 1 - plinth/modules/ikiwiki/views.py | 1 - plinth/modules/infinoted/__init__.py | 1 - plinth/modules/letsencrypt/views.py | 3 ++- plinth/modules/matrixsynapse/views.py | 1 - plinth/modules/mediawiki/views.py | 1 - plinth/modules/minetest/views.py | 1 - plinth/modules/minidlna/views.py | 1 - plinth/modules/mldonkey/urls.py | 1 - plinth/modules/mumble/views.py | 1 - plinth/modules/networks/networks.py | 3 ++- plinth/modules/openvpn/views.py | 3 ++- plinth/modules/privoxy/__init__.py | 1 - plinth/modules/quassel/views.py | 1 - plinth/modules/radicale/views.py | 1 - plinth/modules/repro/__init__.py | 1 - plinth/modules/roundcube/urls.py | 1 - plinth/modules/samba/views.py | 1 - plinth/modules/searx/views.py | 1 - plinth/modules/shadowsocks/views.py | 1 - plinth/modules/syncthing/urls.py | 1 - plinth/modules/tahoe/views.py | 1 - plinth/modules/tor/views.py | 3 ++- plinth/modules/transmission/views.py | 1 - plinth/modules/ttrss/urls.py | 1 - plinth/modules/users/views.py | 1 - plinth/templates/toolbar.html | 4 ++-- plinth/views.py | 5 ++--- 36 files changed, 12 insertions(+), 39 deletions(-) diff --git a/plinth/modules/bind/views.py b/plinth/modules/bind/views.py index e394b396a..fe01456ae 100644 --- a/plinth/modules/bind/views.py +++ b/plinth/modules/bind/views.py @@ -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 diff --git a/plinth/modules/cockpit/views.py b/plinth/modules/cockpit/views.py index a42b81fa6..a7ca6fa53 100644 --- a/plinth/modules/cockpit/views.py +++ b/plinth/modules/cockpit/views.py @@ -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 diff --git a/plinth/modules/coquelicot/views.py b/plinth/modules/coquelicot/views.py index 6a59a4c56..619ccc1b0 100644 --- a/plinth/modules/coquelicot/views.py +++ b/plinth/modules/coquelicot/views.py @@ -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 diff --git a/plinth/modules/datetime/views.py b/plinth/modules/datetime/views.py index a51906bed..519ee72fb 100644 --- a/plinth/modules/datetime/views.py +++ b/plinth/modules/datetime/views.py @@ -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): diff --git a/plinth/modules/deluge/urls.py b/plinth/modules/deluge/urls.py index 80ba1e6ce..4da1fa6dc 100644 --- a/plinth/modules/deluge/urls.py +++ b/plinth/modules/deluge/urls.py @@ -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'), diff --git a/plinth/modules/diaspora/views.py b/plinth/modules/diaspora/views.py index 751c9780a..fd17defc1 100644 --- a/plinth/modules/diaspora/views.py +++ b/plinth/modules/diaspora/views.py @@ -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): diff --git a/plinth/modules/ejabberd/views.py b/plinth/modules/ejabberd/views.py index 65523e4d5..24f86e781 100644 --- a/plinth/modules/ejabberd/views.py +++ b/plinth/modules/ejabberd/views.py @@ -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 diff --git a/plinth/modules/gitweb/views.py b/plinth/modules/gitweb/views.py index da53efe86..469f9ac42 100644 --- a/plinth/modules/gitweb/views.py +++ b/plinth/modules/gitweb/views.py @@ -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' diff --git a/plinth/modules/i2p/views.py b/plinth/modules/i2p/views.py index e36544db1..c40856fa7 100644 --- a/plinth/modules/i2p/views.py +++ b/plinth/modules/i2p/views.py @@ -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 diff --git a/plinth/modules/ikiwiki/views.py b/plinth/modules/ikiwiki/views.py index 2f1f1524e..fae514969 100644 --- a/plinth/modules/ikiwiki/views.py +++ b/plinth/modules/ikiwiki/views.py @@ -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 diff --git a/plinth/modules/infinoted/__init__.py b/plinth/modules/infinoted/__init__.py index 3d2e2d060..12b50d21a 100644 --- a/plinth/modules/infinoted/__init__.py +++ b/plinth/modules/infinoted/__init__.py @@ -102,7 +102,6 @@ def init(): class InfinotedAppView(AppView): app_id = 'infinoted' - diagnostics_module_name = 'infinoted' name = name description = description clients = clients diff --git a/plinth/modules/letsencrypt/views.py b/plinth/modules/letsencrypt/views.py index 183c4ed50..0b0ed16a7 100644 --- a/plinth/modules/letsencrypt/views.py +++ b/plinth/modules/letsencrypt/views.py @@ -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(), }) diff --git a/plinth/modules/matrixsynapse/views.py b/plinth/modules/matrixsynapse/views.py index f7cbcec09..7d21eab5f 100644 --- a/plinth/modules/matrixsynapse/views.py +++ b/plinth/modules/matrixsynapse/views.py @@ -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 diff --git a/plinth/modules/mediawiki/views.py b/plinth/modules/mediawiki/views.py index dddd6eb51..8285587bb 100644 --- a/plinth/modules/mediawiki/views.py +++ b/plinth/modules/mediawiki/views.py @@ -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 diff --git a/plinth/modules/minetest/views.py b/plinth/modules/minetest/views.py index efc0cd85d..f436c5ec9 100644 --- a/plinth/modules/minetest/views.py +++ b/plinth/modules/minetest/views.py @@ -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 diff --git a/plinth/modules/minidlna/views.py b/plinth/modules/minidlna/views.py index edc2d3134..43fde3b91 100644 --- a/plinth/modules/minidlna/views.py +++ b/plinth/modules/minidlna/views.py @@ -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): diff --git a/plinth/modules/mldonkey/urls.py b/plinth/modules/mldonkey/urls.py index 57f1e0500..71f84f5b6 100644 --- a/plinth/modules/mldonkey/urls.py +++ b/plinth/modules/mldonkey/urls.py @@ -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, diff --git a/plinth/modules/mumble/views.py b/plinth/modules/mumble/views.py index 20c05d39a..363856fc3 100644 --- a/plinth/modules/mumble/views.py +++ b/plinth/modules/mumble/views.py @@ -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 diff --git a/plinth/modules/networks/networks.py b/plinth/modules/networks/networks.py index a94e0f17b..ce494ec57 100644 --- a/plinth/modules/networks/networks.py +++ b/plinth/modules/networks/networks.py @@ -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 }) diff --git a/plinth/modules/openvpn/views.py b/plinth/modules/openvpn/views.py index 7b5b989b4..65a0b7f18 100644 --- a/plinth/modules/openvpn/views.py +++ b/plinth/modules/openvpn/views.py @@ -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 }) diff --git a/plinth/modules/privoxy/__init__.py b/plinth/modules/privoxy/__init__.py index dfeeeebe9..f276c9c2d 100644 --- a/plinth/modules/privoxy/__init__.py +++ b/plinth/modules/privoxy/__init__.py @@ -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 diff --git a/plinth/modules/quassel/views.py b/plinth/modules/quassel/views.py index 211b7f9fd..e929fc88e 100644 --- a/plinth/modules/quassel/views.py +++ b/plinth/modules/quassel/views.py @@ -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 diff --git a/plinth/modules/radicale/views.py b/plinth/modules/radicale/views.py index 6e3c25e60..f638022d7 100644 --- a/plinth/modules/radicale/views.py +++ b/plinth/modules/radicale/views.py @@ -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 diff --git a/plinth/modules/repro/__init__.py b/plinth/modules/repro/__init__.py index 96416cad4..83e44a89b 100644 --- a/plinth/modules/repro/__init__.py +++ b/plinth/modules/repro/__init__.py @@ -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 diff --git a/plinth/modules/roundcube/urls.py b/plinth/modules/roundcube/urls.py index 030d858a4..ba3bda5fc 100644 --- a/plinth/modules/roundcube/urls.py +++ b/plinth/modules/roundcube/urls.py @@ -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, diff --git a/plinth/modules/samba/views.py b/plinth/modules/samba/views.py index 53c01678b..f3828d4ad 100644 --- a/plinth/modules/samba/views.py +++ b/plinth/modules/samba/views.py @@ -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 diff --git a/plinth/modules/searx/views.py b/plinth/modules/searx/views.py index f90f2b2fc..2921ee2ac 100644 --- a/plinth/modules/searx/views.py +++ b/plinth/modules/searx/views.py @@ -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 diff --git a/plinth/modules/shadowsocks/views.py b/plinth/modules/shadowsocks/views.py index 19c4633c7..e3590d60c 100644 --- a/plinth/modules/shadowsocks/views.py +++ b/plinth/modules/shadowsocks/views.py @@ -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 diff --git a/plinth/modules/syncthing/urls.py b/plinth/modules/syncthing/urls.py index cc275b9e9..f02869180 100644 --- a/plinth/modules/syncthing/urls.py +++ b/plinth/modules/syncthing/urls.py @@ -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, diff --git a/plinth/modules/tahoe/views.py b/plinth/modules/tahoe/views.py index c30bb3731..1d490f9fe 100644 --- a/plinth/modules/tahoe/views.py +++ b/plinth/modules/tahoe/views.py @@ -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 diff --git a/plinth/modules/tor/views.py b/plinth/modules/tor/views.py index 5df283bbf..59751e5f0 100644 --- a/plinth/modules/tor/views.py +++ b/plinth/modules/tor/views.py @@ -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'], diff --git a/plinth/modules/transmission/views.py b/plinth/modules/transmission/views.py index 0633f9f9e..ff768aa88 100644 --- a/plinth/modules/transmission/views.py +++ b/plinth/modules/transmission/views.py @@ -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 diff --git a/plinth/modules/ttrss/urls.py b/plinth/modules/ttrss/urls.py index d18e08e98..04f9f33a6 100644 --- a/plinth/modules/ttrss/urls.py +++ b/plinth/modules/ttrss/urls.py @@ -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), diff --git a/plinth/modules/users/views.py b/plinth/modules/users/views.py index f2696bb3c..7168a7bb3 100644 --- a/plinth/modules/users/views.py +++ b/plinth/modules/users/views.py @@ -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): diff --git a/plinth/templates/toolbar.html b/plinth/templates/toolbar.html index cbd4947c9..79563c635 100644 --- a/plinth/templates/toolbar.html +++ b/plinth/templates/toolbar.html @@ -50,7 +50,7 @@ {% endwith %} {% endif %} - {% if diagnostics_module_name %} + {% if has_diagnostics %}
diff --git a/plinth/views.py b/plinth/views.py index 4cb7be766..7d6c0fafa 100644 --- a/plinth/views.py +++ b/plinth/views.py @@ -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