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())