From bf63ebaa966f991873611fb58297e358391b0537 Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Fri, 10 May 2019 20:58:56 -0400 Subject: [PATCH] service: Show port forwarding info when available Signed-off-by: James Valleroy Reviewed-by: Sunil Mohan Adapa --- plinth/modules/ejabberd/views.py | 1 + plinth/modules/infinoted/__init__.py | 1 + plinth/modules/minetest/views.py | 1 + plinth/modules/mumble/__init__.py | 1 + plinth/modules/openvpn/views.py | 1 + plinth/modules/quassel/__init__.py | 1 + plinth/templates/service.html | 20 ++++++++++++++++++++ plinth/views.py | 2 ++ 8 files changed, 28 insertions(+) diff --git a/plinth/modules/ejabberd/views.py b/plinth/modules/ejabberd/views.py index c80d1b8d1..896014829 100644 --- a/plinth/modules/ejabberd/views.py +++ b/plinth/modules/ejabberd/views.py @@ -36,6 +36,7 @@ class EjabberdServiceView(ServiceView): diagnostics_module_name = 'ejabberd' form_class = EjabberdForm manual_page = ejabberd.manual_page + port_forwarding_info = ejabberd.port_forwarding_info def get_initial(self): initdict = super().get_initial() diff --git a/plinth/modules/infinoted/__init__.py b/plinth/modules/infinoted/__init__.py index 0f7f5f3e7..38d930952 100644 --- a/plinth/modules/infinoted/__init__.py +++ b/plinth/modules/infinoted/__init__.py @@ -78,6 +78,7 @@ class InfinotedServiceView(ServiceView): diagnostics_module_name = "infinoted" description = description clients = clients + port_forwarding_info = port_forwarding_info def setup(helper, old_version=None): diff --git a/plinth/modules/minetest/views.py b/plinth/modules/minetest/views.py index dd400d27a..aa4a2654c 100644 --- a/plinth/modules/minetest/views.py +++ b/plinth/modules/minetest/views.py @@ -39,6 +39,7 @@ class MinetestServiceView(ServiceView): # pylint: disable=too-many-ancestors form_class = MinetestForm clients = minetest.clients manual_page = minetest.manual_page + port_forwarding_info = minetest.port_forwarding_info def get_initial(self): """Return the values to fill in the form.""" diff --git a/plinth/modules/mumble/__init__.py b/plinth/modules/mumble/__init__.py index 3e5f11de7..a315939c3 100644 --- a/plinth/modules/mumble/__init__.py +++ b/plinth/modules/mumble/__init__.py @@ -83,6 +83,7 @@ class MumbleServiceView(ServiceView): description = description clients = clients manual_page = manual_page + port_forwarding_info = port_forwarding_info def setup(helper, old_version=None): diff --git a/plinth/modules/openvpn/views.py b/plinth/modules/openvpn/views.py index 255951402..ecb260030 100644 --- a/plinth/modules/openvpn/views.py +++ b/plinth/modules/openvpn/views.py @@ -61,6 +61,7 @@ def index(request): 'title': openvpn.name, 'description': openvpn.description, 'manual_page': openvpn.manual_page, + 'port_forwarding_info': openvpn.port_forwarding_info, 'status': status, 'form': form }) diff --git a/plinth/modules/quassel/__init__.py b/plinth/modules/quassel/__init__.py index 6b1250253..69d3f1509 100644 --- a/plinth/modules/quassel/__init__.py +++ b/plinth/modules/quassel/__init__.py @@ -89,6 +89,7 @@ class QuasselServiceView(ServiceView): description = description clients = clients manual_page = manual_page + port_forwarding_info = port_forwarding_info def setup(helper, old_version=None): diff --git a/plinth/templates/service.html b/plinth/templates/service.html index e8b05fe8c..bf5f4c145 100644 --- a/plinth/templates/service.html +++ b/plinth/templates/service.html @@ -75,6 +75,26 @@ {% include "internal-zone.html" %} + {% if port_forwarding_info %} +

{% trans "Port Forwarding" %}

+ +

+ {% with service_name=service.name %} + {% blocktrans trimmed %} + If your FreedomBox is behind a router, you will need to set up port + forwarding on your router. You should forward the following ports for + {{ service_name }}: + {% endblocktrans %} + {% endwith %} +

+ +
    + {% for port in port_forwarding_info %} +
  • {{ port.0 }} {{ port.1 }}
  • + {% endfor %} +
+ {% endif %} + {% block configuration %}

{% trans "Configuration" %}

diff --git a/plinth/views.py b/plinth/views.py index df182cde0..566cbcbb6 100644 --- a/plinth/views.py +++ b/plinth/views.py @@ -122,6 +122,7 @@ class ServiceView(FormView): service_id = None template_name = 'service.html' manual_page = "" + port_forwarding_info = None @property def success_url(self): @@ -177,6 +178,7 @@ class ServiceView(FormView): context['description'] = self.description context['show_status_block'] = self.show_status_block context['manual_page'] = self.manual_page + context['port_forwarding_info'] = self.port_forwarding_info return context