diff --git a/plinth/templates/setup.html b/plinth/templates/setup.html new file mode 100644 index 000000000..4cd25ee0f --- /dev/null +++ b/plinth/templates/setup.html @@ -0,0 +1,101 @@ +{% extends "base.html" %} +{% comment %} +# +# 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 . +# +{% endcomment %} + +{% load bootstrap %} +{% load i18n %} + +{% block page_head %} + + {% if setup_helper.current_operation %} + + {% endif %} + +{% endblock %} + + +{% block content %} + +

{% trans "Installation" %}: {{ setup_helper.module.title }}

+ + {% for paragraph in setup_helper.module.description %} +

{{ paragraph|safe }}

+ {% endfor %} + + {% if not setup_helper.current_operation %} + + {% if setup_helper.get_state == 'needs-setup' %} +

+ {% blocktrans trimmed %} + Install this application? + {% endblocktrans %} +

+ +
+ {% csrf_token %} + + +
+ {% elif setup_helper.get_state == 'needs-update' %} +

+ {% blocktrans trimmed %} + This application needs an update. Update now? + {% endblocktrans %} +

+ +
+ {% csrf_token %} + + +
+ {% endif %} + + {% else %} + + {% if setup_helper.current_operation.step == 'pre' %} + {% trans "Performing pre-install operation" %} + {% elif setup_helper.current_operation.step == 'post' %} + {% trans "Performing post-install operation" %} + {% elif setup_helper.current_operation.step == 'install' %} + {% with transaction=setup_helper.current_operation.transaction %} +
+ {% blocktrans trimmed with package_names=transaction.package_names|join:", " status=transaction.status_string %} + Installing {{ package_names }}: {{ status }} + {% endblocktrans %} +
+
+
+ + {% blocktrans trimmed with percentage=transaction.percentage %} + {{ percentage }}% complete + {% endblocktrans %} + +
+
+ {% endwith %} + {% endif %} + + {% endif %} + +{% endblock %} diff --git a/plinth/views.py b/plinth/views.py index cfbbd608b..8cee96adf 100644 --- a/plinth/views.py +++ b/plinth/views.py @@ -22,6 +22,7 @@ Main Plinth views from django.core.urlresolvers import reverse from django.http.response import HttpResponseRedirect from django.views.generic import TemplateView +import time from plinth import package as package_module @@ -61,3 +62,28 @@ class PackageInstallView(TemplateView): before_install=self.kwargs.get('before_install'), on_install=self.kwargs.get('on_install')) return self.render_to_response(self.get_context_data()) + + +class SetupView(TemplateView): + """View to prompt and setup applications.""" + template_name = 'setup.html' + + def get_context_data(self, **kwargs): + """Return the context data rendering the template.""" + context = super(SetupView, self).get_context_data(**kwargs) + context['setup_helper'] = self.kwargs['setup_helper'] + return context + + def post(self, *args, **kwargs): + """Handle installing/upgrading applications. + + Start the application setup, and refresh the page every few + seconds to keep displaying the status. + """ + self.kwargs['setup_helper'].run_in_thread() + + # Give a moment for the setup process to start and show + # meaningful status. + time.sleep(1) + + return self.render_to_response(self.get_context_data())