+ {% endfor %}
+
+ {% endif %}
+
+{% endblock %}
diff --git a/plinth/views.py b/plinth/views.py
index 481911979..81a58c022 100644
--- a/plinth/views.py
+++ b/plinth/views.py
@@ -19,13 +19,61 @@
Main Plinth views
"""
+from django.core.exceptions import ImproperlyConfigured
from django.core.urlresolvers import reverse
from django.http.response import HttpResponseRedirect
+from django.views.generic.edit import FormView
+
+from plinth import package as package_module
+from plinth.forms import PackageInstallForm
def index(request):
- """Serve the main index page"""
+ """Serve the main index page."""
if request.user.is_authenticated():
return HttpResponseRedirect(reverse('apps:index'))
return HttpResponseRedirect(reverse('help:about'))
+
+
+class PackageInstallView(FormView):
+ """View to prompt and install packages."""
+ template_name = 'package_install.html'
+ form_class = PackageInstallForm
+
+ def get_context_data(self, **kwargs):
+ """Return the context data rendering the template."""
+ context = super(PackageInstallView, self).get_context_data(**kwargs)
+ if 'packages_names' not in context:
+ context['package_names'] = self.kwargs.get('package_names', [])
+
+ # Package details must have been resolved before building the form
+ context['packages'] = [package_module.packages_resolved[package_name]
+ for package_name in context['package_names']]
+ context['is_installing'] = \
+ package_module.is_installing(context['package_names'])
+ context['transactions'] = package_module.transactions
+
+ return context
+
+ def get_initial(self):
+ """Return the initial data to be filled in the form."""
+ initial = super(PackageInstallView, self).get_initial()
+ try:
+ initial['package_names'] = ','.join(self.kwargs['package_names'])
+ except KeyError:
+ raise ImproperlyConfigured('Argument package_names must be '
+ 'provided to PackageInstallView')
+
+ return initial
+
+ def form_valid(self, form):
+ """Handle successful validation of the form.
+
+ Start the package installation and show this view again.
+ """
+ package_names = form.cleaned_data['package_names'].split(',')
+ package_module.start_install(package_names)
+
+ return self.render_to_response(
+ self.get_context_data(package_names=package_names))
diff --git a/setup.py b/setup.py
index 970a0f8de..1e0d85247 100755
--- a/setup.py
+++ b/setup.py
@@ -114,7 +114,8 @@ setuptools.setup(
install_requires=[
'cherrypy >= 3.0',
'django >= 1.7.0',
- 'django-bootstrap-form'
+ 'django-bootstrap-form',
+ 'pygobject'
],
tests_require=['coverage >= 3.7'],
include_package_data=True,
From 9b9d112927d6cc895bc7847c127ff97630e2a5a5 Mon Sep 17 00:00:00 2001
From: Sunil Mohan Adapa
Date: Sun, 21 Dec 2014 17:24:11 +0530
Subject: [PATCH 24/30] Use package framework for installing ownCloud
---
actions/owncloud-setup | 8 --------
plinth/modules/owncloud/owncloud.py | 2 ++
plinth/modules/owncloud/templates/owncloud.html | 8 ++------
3 files changed, 4 insertions(+), 14 deletions(-)
diff --git a/actions/owncloud-setup b/actions/owncloud-setup
index 3b82d0c9e..c221acd2e 100755
--- a/actions/owncloud-setup
+++ b/actions/owncloud-setup
@@ -58,14 +58,6 @@ done
if [ "$owncloud_enable" != "$owncloud_enable_cur" ] ; then
if $owncloud_enable ; then
- # Select postgresql as the backend database for OwnCloud, and
- # make sure its php support is enabled when owncloud is
- # installed.
- DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends \
- install -y postgresql php5-pgsql 2>&1 | logger -t owncloud-setup
- DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends \
- install -y owncloud 2>&1 | logger -t owncloud-setup
-
# Keep existing configuration if it exist
if [ ! -e /etc/owncloud/config.php ] ; then
# Set up postgresql database and user
diff --git a/plinth/modules/owncloud/owncloud.py b/plinth/modules/owncloud/owncloud.py
index 0fc143744..cd3402d8d 100644
--- a/plinth/modules/owncloud/owncloud.py
+++ b/plinth/modules/owncloud/owncloud.py
@@ -23,6 +23,7 @@ from gettext import gettext as _
from plinth import actions
from plinth import cfg
+from plinth import package
from plinth import service
@@ -47,6 +48,7 @@ def init():
@login_required
+@package.required('postgresql', 'php5-pgsql', 'owncloud')
def index(request):
"""Serve the ownCloud configuration page"""
status = get_status()
diff --git a/plinth/modules/owncloud/templates/owncloud.html b/plinth/modules/owncloud/templates/owncloud.html
index 663e1893f..f18dc211b 100644
--- a/plinth/modules/owncloud/templates/owncloud.html
+++ b/plinth/modules/owncloud/templates/owncloud.html
@@ -27,14 +27,10 @@
ownCloud
-
When enabled, the owncloud installation will be available
+
When enabled, the ownCloud installation will be available
from /owncloud path on the web server.
Visit this URL to set up the initial administration account for
- owncloud.
-
-
Note: Setting up owncloud for the first time might take
- 5 minutes or more, depending on download bandwidth from the
- Debian APT sources.
+ ownCloud.
{{ form|bootstrap }}
From d79f346591222468552e38e71ad1c6422c46df00 Mon Sep 17 00:00:00 2001
From: Sunil Mohan Adapa
Date: Mon, 22 Dec 2014 23:27:16 +0530
Subject: [PATCH 25/30] Use package framework for installing firewalld
---
actions/firewall | 12 ------------
plinth/modules/firewall/firewall.py | 15 +++------------
plinth/modules/firewall/templates/firewall.html | 8 +-------
3 files changed, 4 insertions(+), 31 deletions(-)
diff --git a/actions/firewall b/actions/firewall
index 98d40fe8d..cae05e86c 100755
--- a/actions/firewall
+++ b/actions/firewall
@@ -30,10 +30,6 @@ def parse_arguments():
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(dest='subcommand', help='Sub command')
- # Get installed status
- subparsers.add_parser('get-installed',
- help='Get whether firewalld is installed')
-
# Get status
subparsers.add_parser('get-status',
help='Get whether firewalld is running')
@@ -64,14 +60,6 @@ def parse_arguments():
return parser.parse_args()
-def subcommand_get_installed(_):
- """Print whether firewalld is installed"""
- with open('/dev/null', 'w') as file_handle:
- status = subprocess.call(['which', 'firewalld'], stdout=file_handle)
-
- print('installed' if not status else 'not installed')
-
-
def subcommand_get_status(_):
"""Print status of the firewalld service"""
subprocess.call(['firewall-cmd', '--state'])
diff --git a/plinth/modules/firewall/firewall.py b/plinth/modules/firewall/firewall.py
index 906573286..189762255 100644
--- a/plinth/modules/firewall/firewall.py
+++ b/plinth/modules/firewall/firewall.py
@@ -26,6 +26,7 @@ import logging
from plinth import actions
from plinth import cfg
+from plinth import package
from plinth.signals import service_enabled
import plinth.service as service_module
@@ -42,13 +43,9 @@ def init():
@login_required
+@package.required('firewalld')
def index(request):
"""Serve introcution page"""
- if not get_installed_status():
- return TemplateResponse(request, 'firewall.html',
- {'title': _('Firewall'),
- 'firewall_status': 'not_installed'})
-
if not get_enabled_status():
return TemplateResponse(request, 'firewall.html',
{'title': _('Firewall'),
@@ -65,14 +62,8 @@ def index(request):
'external_enabled_services': external_enabled_services})
-def get_installed_status():
- """Return whether firewall is installed"""
- output = _run(['get-installed'], superuser=True)
- return output.split()[0] == 'installed'
-
-
def get_enabled_status():
- """Return whether firewall is installed"""
+ """Return whether firewall is enabled"""
output = _run(['get-status'], superuser=True)
return output.split()[0] == 'running'
diff --git a/plinth/modules/firewall/templates/firewall.html b/plinth/modules/firewall/templates/firewall.html
index aa4ea3eb6..5eac0b6db 100644
--- a/plinth/modules/firewall/templates/firewall.html
+++ b/plinth/modules/firewall/templates/firewall.html
@@ -29,13 +29,7 @@ threat from the Internet.
The following is the current status:
-{% if firewall_status = 'not_installed' %}
-
Firewall is not installed. Please install it. Firewall comes
-pre-installed with {{ cfg.box_name }}. On any Debian based system (such
-as {{ cfg.box_name }}) you may install it using the
-command aptitude install firewalld
Firewall daemon is not running. Please run it. Firewall comes
enabled by default on {{ cfg.box_name }}. On any Debian based system
From 7b45ad1813aeea97f8180304618282654274d6ee Mon Sep 17 00:00:00 2001
From: Sunil Mohan Adapa
Date: Mon, 22 Dec 2014 23:29:15 +0530
Subject: [PATCH 26/30] Use package framework for installing pagekite
---
actions/pagekite-configure | 12 ------------
plinth/modules/pagekite/pagekite.py | 7 ++-----
.../pagekite/templates/pagekite_configure.html | 11 -----------
3 files changed, 2 insertions(+), 28 deletions(-)
diff --git a/actions/pagekite-configure b/actions/pagekite-configure
index 8a22142a5..a5af96fb0 100755
--- a/actions/pagekite-configure
+++ b/actions/pagekite-configure
@@ -48,10 +48,6 @@ def parse_arguments():
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(dest='subcommand', help='Sub command')
- # Get installed status
- subparsers.add_parser('get-installed',
- help='Get whether PakeKite is installed')
-
# Start PageKite
subparsers.add_parser('start', help='Start PageKite service')
@@ -91,14 +87,6 @@ def parse_arguments():
return parser.parse_args()
-def subcommand_get_installed(_):
- """Print whether PageKite is installed"""
- with open('/dev/null', 'w') as file_handle:
- status = subprocess.call(['which', 'pagekite'], stdout=file_handle)
-
- print('installed' if not status else 'not installed')
-
-
def subcommand_start(_):
"""Start PageKite service"""
status = subprocess.call(['service', 'pagekite', 'start'])
diff --git a/plinth/modules/pagekite/pagekite.py b/plinth/modules/pagekite/pagekite.py
index 9f435b77e..519a7b0fd 100644
--- a/plinth/modules/pagekite/pagekite.py
+++ b/plinth/modules/pagekite/pagekite.py
@@ -30,6 +30,7 @@ import logging
from plinth import actions
from plinth import cfg
+from plinth import package
LOGGER = logging.getLogger(__name__)
@@ -101,6 +102,7 @@ https://pagekite.net/wiki/Howto/SshOverPageKite/">instructions'))
@login_required
+@package.required('pagekite')
def configure(request):
"""Serve the configuration form"""
status = get_status()
@@ -131,11 +133,6 @@ def get_status():
"""
status = {}
- # Check if PageKite is installed
- output = _run(['get-installed'])
- if output.split()[0] != 'installed':
- return None
-
# PageKite service enabled/disabled
output = _run(['get-status'])
status['enabled'] = (output.split()[0] == 'enabled')
diff --git a/plinth/modules/pagekite/templates/pagekite_configure.html b/plinth/modules/pagekite/templates/pagekite_configure.html
index e41436a56..0d737ba9b 100644
--- a/plinth/modules/pagekite/templates/pagekite_configure.html
+++ b/plinth/modules/pagekite/templates/pagekite_configure.html
@@ -22,15 +22,6 @@
{% block content %}
-{% if not status %}
-
-
PageKite is not installed, please install it. PageKite comes
- pre-installed with {{ cfg.box_name }}. On any Debian based system
- (such as {{ cfg.box_name }}) you may install it using the command
- aptitude install pagekite
-
-{% else %}
-
-{% endif %}
-
{% endblock %}
{% block page_js %}
From c7f27e493eedef7a35e5ea9aa7fa45ab02f608ed Mon Sep 17 00:00:00 2001
From: Sunil Mohan Adapa
Date: Mon, 22 Dec 2014 23:31:50 +0530
Subject: [PATCH 27/30] Use package framework for installing tor
---
actions/tor | 27 ++-------------------------
plinth/modules/tor/templates/tor.html | 11 -----------
plinth/modules/tor/tor.py | 9 +++------
3 files changed, 5 insertions(+), 42 deletions(-)
diff --git a/actions/tor b/actions/tor
index 0c2cdbfb0..f72c7fd5e 100755
--- a/actions/tor
+++ b/actions/tor
@@ -34,10 +34,6 @@ def parse_arguments():
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(dest='subcommand', help='Sub command')
- # Get whether Tor is installed
- subparsers.add_parser('get-installed',
- help='Get whether Tor is installed')
-
# Get whether Tor is running
subparsers.add_parser('is-running', help='Get whether Tor is running')
@@ -59,11 +55,6 @@ def parse_arguments():
return parser.parse_args()
-def subcommand_get_installed(_):
- """Get whether Tor is installed"""
- print('installed' if get_installed() else 'not installed')
-
-
def subcommand_is_running(_):
"""Get whether Tor is running"""
try:
@@ -101,7 +92,7 @@ def subcommand_get_hs(_):
def subcommand_enable_hs(_):
"""Enable Tor hidden service"""
- if not get_installed() or get_hidden_service():
+ if get_hidden_service():
return
with open(TOR_CONFIG, 'r') as conffile:
@@ -121,7 +112,7 @@ def subcommand_enable_hs(_):
def subcommand_disable_hs(_):
"""Disable Tor hidden service"""
- if not get_installed() or not get_hidden_service():
+ if not get_hidden_service():
return
with open(TOR_CONFIG, 'r') as conffile:
@@ -154,19 +145,8 @@ def subcommand_disable_hs(_):
subprocess.call(['service', 'tor', 'restart'])
-def get_installed():
- """Get whether Tor is installed"""
- with open('/dev/null', 'w') as file_handle:
- status = subprocess.call(['which', 'tor'], stdout=file_handle)
-
- return not status
-
-
def set_tor_service(enable):
"""Enable/disable Tor service; enable: boolean"""
- if not get_installed():
- return
-
newline = 'RUN_DAEMON="yes"\n' if enable else 'RUN_DAEMON="no"\n'
with open(SERVICE_CONFIG, 'r') as file:
@@ -182,9 +162,6 @@ def set_tor_service(enable):
def get_hidden_service():
"""Return a string with configured Tor hidden service information"""
- if not get_installed():
- return ''
-
hs_dir = None
hs_ports = []
diff --git a/plinth/modules/tor/templates/tor.html b/plinth/modules/tor/templates/tor.html
index 73d571232..7d43c2457 100644
--- a/plinth/modules/tor/templates/tor.html
+++ b/plinth/modules/tor/templates/tor.html
@@ -24,8 +24,6 @@
Tor
-{% if is_installed %}
-
Status
@@ -80,15 +78,6 @@ port-forwarded, if necessary:
A Tor SOCKS port is available on your {{ cfg.box_name }} on TCP port
9050.
-{% else %}
-
-
Tor is not installed, please install it. Tor comes pre-installed
- with {{ cfg.box_name }}. On any Debian-based system (such as
- {{ cfg.box_name }}) you may install it using the command
- aptitude install tor.
-
-{% endif %}
-
{% endblock %}
{% block sidebar %}
diff --git a/plinth/modules/tor/tor.py b/plinth/modules/tor/tor.py
index 9c2fa4308..7e300d169 100644
--- a/plinth/modules/tor/tor.py
+++ b/plinth/modules/tor/tor.py
@@ -27,6 +27,7 @@ from gettext import gettext as _
from plinth import actions
from plinth import cfg
+from plinth import package
class TorForm(forms.Form): # pylint: disable=W0232
@@ -43,6 +44,7 @@ def init():
@login_required
+@package.required('tor')
def index(request):
"""Service the index page"""
status = get_status()
@@ -61,7 +63,6 @@ def index(request):
return TemplateResponse(request, 'tor.html',
{'title': _('Tor Control Panel'),
- 'is_installed': status['is_installed'],
'is_running': status['is_running'],
'tor_ports': status['ports'],
'tor_hs_enabled': status['hs_enabled'],
@@ -72,9 +73,6 @@ def index(request):
def get_status():
"""Return the current status"""
- is_installed = actions.superuser_run(
- 'tor',
- ['get-installed']).strip() == 'installed'
is_running = actions.superuser_run('tor', ['is-running']).strip() == 'yes'
output = actions.superuser_run('tor-get-ports')
@@ -103,8 +101,7 @@ def get_status():
hs_hostname = hs_info[0]
hs_ports = hs_info[1]
- return {'is_installed': is_installed,
- 'is_running': is_running,
+ return {'is_running': is_running,
'ports': ports,
'hs_enabled': hs_enabled,
'hs_hostname': hs_hostname,
From b3e8e53c73a313358a2a20bb4bebe619a7d66a57 Mon Sep 17 00:00:00 2001
From: Sunil Mohan Adapa
Date: Mon, 22 Dec 2014 23:34:16 +0530
Subject: [PATCH 28/30] Use package framework for installing ejabberd and
jwchat
---
actions/xmpp | 33 -------------------------
plinth/modules/xmpp/templates/xmpp.html | 14 -----------
plinth/modules/xmpp/xmpp.py | 14 +++--------
3 files changed, 3 insertions(+), 58 deletions(-)
diff --git a/actions/xmpp b/actions/xmpp
index ea2d0c29e..115fe375c 100755
--- a/actions/xmpp
+++ b/actions/xmpp
@@ -38,10 +38,6 @@ def parse_arguments():
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(dest='subcommand', help='Sub command')
- # Get whether ejabberd is installed
- subparsers.add_parser('get-installed',
- help='Get whether ejabberd is installed')
-
# Prepare ejabberd for hostname change
pre_hostname_change = subparsers.add_parser(
'pre-change-hostname',
@@ -77,17 +73,8 @@ def parse_arguments():
return parser.parse_args()
-def subcommand_get_installed(_):
- """Get whether ejabberd is installed"""
- print('installed' if get_installed() else 'not installed')
-
-
def subcommand_pre_change_hostname(arguments):
"""Prepare ejabberd for hostname change"""
- if not get_installed():
- print('Failed to update XMPP hostname: ejabberd is not installed.')
- return
-
old_hostname = arguments.old_hostname
new_hostname = arguments.new_hostname
@@ -104,10 +91,6 @@ def subcommand_pre_change_hostname(arguments):
def subcommand_change_hostname(arguments):
"""Update ejabberd and jwchat with new hostname"""
- if not get_installed():
- print('Failed to update XMPP hostname: ejabberd is not installed.')
- return
-
subprocess.call(['service', 'ejabberd', 'stop'])
subprocess.call(['pkill', '-u', 'ejabberd'])
@@ -134,10 +117,6 @@ def subcommand_change_hostname(arguments):
def subcommand_change_domainname(arguments):
"""Update ejabberd and jwchat with new domainname"""
- if not get_installed():
- print('Failed to update XMPP domainname: ejabberd is not installed.')
- return
-
domainname = arguments.domainname
fqdn = socket.gethostname() + '.' + domainname
@@ -172,10 +151,6 @@ def subcommand_change_domainname(arguments):
def subcommand_register(arguments):
"""Register a new user account"""
- if not get_installed():
- print('Failed to register XMPP account: ejabberd is not installed.')
- return
-
username = arguments.username
password = arguments.password
fqdn = socket.getfqdn()
@@ -188,14 +163,6 @@ def subcommand_register(arguments):
print('Failed to register XMPP account:', e.output.decode())
-def get_installed():
- """Check if ejabberd is installed"""
- with open('/dev/null', 'w') as file_handle:
- status = subprocess.call(['which', 'ejabberdctl'], stdout=file_handle)
-
- return not status
-
-
def main():
"""Parse arguments and perform all duties"""
arguments = parse_arguments()
diff --git a/plinth/modules/xmpp/templates/xmpp.html b/plinth/modules/xmpp/templates/xmpp.html
index 1a8659e47..7a81d9b8a 100644
--- a/plinth/modules/xmpp/templates/xmpp.html
+++ b/plinth/modules/xmpp/templates/xmpp.html
@@ -22,8 +22,6 @@
{% block content %}
-{% if is_installed %}
-
XMPP is an open and standardized communication protocol. Here you
can run and configure your XMPP server, called ejabberd. To actually
communicate, you can use the web client or any
@@ -33,16 +31,4 @@
ejabberd comes pre-installed with {{ cfg.box_name }}. On any Debian-based
- system (such as {{ cfg.box_name }}) you may install it using the command
- aptitude install ejabberd.
-
-{% endif %}
-
{% endblock %}
diff --git a/plinth/modules/xmpp/xmpp.py b/plinth/modules/xmpp/xmpp.py
index 8a38ec2bb..718c981e5 100644
--- a/plinth/modules/xmpp/xmpp.py
+++ b/plinth/modules/xmpp/xmpp.py
@@ -25,6 +25,7 @@ import logging
from plinth import actions
from plinth import cfg
+from plinth import package
from plinth import service
from plinth.signals import pre_hostname_change, post_hostname_change
from plinth.signals import domainname_change
@@ -61,21 +62,12 @@ def init():
@login_required
+@package.required('jwchat', 'ejabberd')
def index(request):
"""Serve XMPP page"""
- is_installed = actions.superuser_run(
- 'xmpp',
- ['get-installed']).strip() == 'installed'
-
- if is_installed:
- index_subsubmenu = subsubmenu
- else:
- index_subsubmenu = None
-
return TemplateResponse(request, 'xmpp.html',
{'title': _('XMPP Server'),
- 'is_installed': is_installed,
- 'subsubmenu': index_subsubmenu})
+ 'subsubmenu': subsubmenu})
class ConfigureForm(forms.Form): # pylint: disable-msg=W0232
From e905d1a8f24f616d835e5bfc5f87329e3609ec23 Mon Sep 17 00:00:00 2001
From: fonfon
Date: Sat, 27 Dec 2014 13:59:09 +0100
Subject: [PATCH 29/30] packagekit: use TemplateView instead of FormView
For the installation procedure a TemplateView is sufficient, and the user
won't be able to edit any form-data on the client-side.
---
plinth/forms.py | 33 -------------------------
plinth/templates/package_install.html | 3 ---
plinth/views.py | 35 +++++++--------------------
3 files changed, 9 insertions(+), 62 deletions(-)
delete mode 100644 plinth/forms.py
diff --git a/plinth/forms.py b/plinth/forms.py
deleted file mode 100644
index aa3ee74b4..000000000
--- a/plinth/forms.py
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# This file is part of Plinth.
-#
-# 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 .
-#
-
-"""
-Plinth framework forms
-"""
-
-from django import forms
-
-
-class PackageInstallForm(forms.Form):
- """Prompt for installation of a package.
-
- XXX: Don't store the package list in a hidden input as it can be
- modified on the client side. Use session store to store and retrieve
- the package list. It has to be form specific so that multiple
- instances of forms don't clash with each other.
- """
- package_names = forms.CharField(widget=forms.HiddenInput)
diff --git a/plinth/templates/package_install.html b/plinth/templates/package_install.html
index 0624a8898..f853a3e2c 100644
--- a/plinth/templates/package_install.html
+++ b/plinth/templates/package_install.html
@@ -55,9 +55,6 @@
diff --git a/plinth/views.py b/plinth/views.py
index 81a58c022..e63501af5 100644
--- a/plinth/views.py
+++ b/plinth/views.py
@@ -19,13 +19,11 @@
Main Plinth views
"""
-from django.core.exceptions import ImproperlyConfigured
from django.core.urlresolvers import reverse
from django.http.response import HttpResponseRedirect
-from django.views.generic.edit import FormView
+from django.views.generic import TemplateView
from plinth import package as package_module
-from plinth.forms import PackageInstallForm
def index(request):
@@ -36,18 +34,16 @@ def index(request):
return HttpResponseRedirect(reverse('help:about'))
-class PackageInstallView(FormView):
+class PackageInstallView(TemplateView):
"""View to prompt and install packages."""
template_name = 'package_install.html'
- form_class = PackageInstallForm
def get_context_data(self, **kwargs):
"""Return the context data rendering the template."""
context = super(PackageInstallView, self).get_context_data(**kwargs)
+
if 'packages_names' not in context:
context['package_names'] = self.kwargs.get('package_names', [])
-
- # Package details must have been resolved before building the form
context['packages'] = [package_module.packages_resolved[package_name]
for package_name in context['package_names']]
context['is_installing'] = \
@@ -56,24 +52,11 @@ class PackageInstallView(FormView):
return context
- def get_initial(self):
- """Return the initial data to be filled in the form."""
- initial = super(PackageInstallView, self).get_initial()
- try:
- initial['package_names'] = ','.join(self.kwargs['package_names'])
- except KeyError:
- raise ImproperlyConfigured('Argument package_names must be '
- 'provided to PackageInstallView')
+ def post(self, *args, **kwargs):
+ """Handle installing packages
- return initial
-
- def form_valid(self, form):
- """Handle successful validation of the form.
-
- Start the package installation and show this view again.
+ Start the package installation, and refresh the page every x seconds to
+ keep displaying PackageInstallView.get() with the installation status.
"""
- package_names = form.cleaned_data['package_names'].split(',')
- package_module.start_install(package_names)
-
- return self.render_to_response(
- self.get_context_data(package_names=package_names))
+ package_module.start_install(self.kwargs['package_names'])
+ return self.render_to_response(self.get_context_data())
From 2015b52798610fd8830a93b789398d92dcf95874 Mon Sep 17 00:00:00 2001
From: Sunil Mohan Adapa
Date: Mon, 5 Jan 2015 02:38:48 +0530
Subject: [PATCH 30/30] Release 0.4.2
---
plinth/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plinth/__init__.py b/plinth/__init__.py
index 4a9b47e83..387fc2ce7 100644
--- a/plinth/__init__.py
+++ b/plinth/__init__.py
@@ -19,4 +19,4 @@
Plinth package init file
"""
-__version__ = '0.4.1'
+__version__ = '0.4.2'