From b916d95a0b3f15efb8c2b67f6a761783eddebae7 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Fri, 12 Feb 2016 16:14:59 +0530 Subject: [PATCH] openvpn: Use new setup mechanism --- plinth/modules/openvpn/__init__.py | 27 ++++++++++++++++--- plinth/modules/openvpn/templates/openvpn.html | 18 ++----------- plinth/modules/openvpn/views.py | 5 ++-- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/plinth/modules/openvpn/__init__.py b/plinth/modules/openvpn/__init__.py index 688b1507f..c035abb99 100644 --- a/plinth/modules/openvpn/__init__.py +++ b/plinth/modules/openvpn/__init__.py @@ -25,23 +25,42 @@ from plinth import actions from plinth import action_utils from plinth import cfg from plinth import service as service_module +from plinth.utils import format_lazy +version = 1 + depends = ['apps'] +title = _('Virtual Private Network (OpenVPN)') + +description = [ + format_lazy( + _('Virtual Private Network (VPN) is a technique for securely ' + 'connecting two devices in order to access resources of a ' + 'private network. While you are away from home, you can connect ' + 'to your {box_name} in order to join your home network and ' + 'access private/internal services provided by {box_name}. ' + 'You can also access the rest of the Internet via {box_name} ' + 'for added security and anonymity.'), box_name=_(cfg.box_name)) +] + service = None def init(): """Intialize the OpenVPN module.""" menu = cfg.main_menu.get('apps:index') - menu.add_urlname(_('Virtual Private Network (OpenVPN)'), 'glyphicon-lock', - 'openvpn:index', 850) + menu.add_urlname(title, 'glyphicon-lock', 'openvpn:index', 850) global service service = service_module.Service( - 'openvpn', _('OpenVPN'), ['openvpn'], - is_external=True, enabled=is_enabled()) + 'openvpn', title, ['openvpn'], is_external=True, enabled=is_enabled()) + + +def setup(helper, old_version=None): + """Install and configure the module.""" + helper.install(['openvpn', 'easy-rsa']) def is_enabled(): diff --git a/plinth/modules/openvpn/templates/openvpn.html b/plinth/modules/openvpn/templates/openvpn.html index d2ff0c5d8..422a9e69f 100644 --- a/plinth/modules/openvpn/templates/openvpn.html +++ b/plinth/modules/openvpn/templates/openvpn.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "app.html" %} {% comment %} # # This file is part of Plinth. @@ -30,21 +30,7 @@ {% endblock %} -{% block content %} - -

{% trans "Virtual Private Network (OpenVPN)" %}

- -

- {% blocktrans trimmed %} - Virtual Private Network (VPN) is a technique for securely - connecting two devices in order to access resources of a - private network. While you are away from home, you can connect - to your {{ box_name }} in order to join your home network and - access private/internal services provided by {{ box_name }}. - You can also access the rest of the Internet via {{ box_name }} - for added security and anonymity. - {% endblocktrans %} -

+{% block configuration %} {% if status.is_setup %} diff --git a/plinth/modules/openvpn/views.py b/plinth/modules/openvpn/views.py index f4cd85ed8..ea1c6aefa 100644 --- a/plinth/modules/openvpn/views.py +++ b/plinth/modules/openvpn/views.py @@ -29,7 +29,6 @@ import logging from .forms import OpenVpnForm from plinth import actions -from plinth import package from plinth.modules import openvpn from plinth.modules.config import config @@ -38,7 +37,6 @@ logger = logging.getLogger(__name__) setup_process = None -@package.required(['openvpn', 'easy-rsa']) def index(request): """Serve configuration page.""" status = get_status() @@ -59,7 +57,8 @@ def index(request): form = OpenVpnForm(initial=status, prefix='openvpn') return TemplateResponse(request, 'openvpn.html', - {'title': _('Virtual Private Network (OpenVPN)'), + {'title': openvpn.title, + 'description': openvpn.description, 'status': status, 'form': form})