diff --git a/plinth/modules/upgrades/templates/update-firstboot-progress.html b/plinth/modules/upgrades/templates/update-firstboot-progress.html new file mode 100644 index 000000000..e0a9db852 --- /dev/null +++ b/plinth/modules/upgrades/templates/update-firstboot-progress.html @@ -0,0 +1,50 @@ +{% extends "base_firstboot.html" %} +{% comment %} +# SPDX-License-Identifier: AGPL-3.0-or-later +{% endcomment %} + +{% load bootstrap %} +{% load i18n %} +{% load static %} + +{% block page_head %} + +{% endblock %} + +{% block content %} +

{% trans "Update" %}

+ + {% if is_busy %} +
+
+ +
+

+ {% trans "Updating, please wait..." %} +

+

+ {% blocktrans trimmed %} + This may take a long time to complete. During + an update, this web interface may be temporarily unavailable and + show an error. In that case, refresh the page to continue. + {% endblocktrans %} +

+
+ {% else %} +

+ {% blocktrans %} + {{ box_name }} is up to date. Press Next to continue. + {% endblocktrans %} +

+ + {% trans 'Next' %} + + {% endif %} + +{% endblock %} diff --git a/plinth/modules/upgrades/templates/update-firstboot.html b/plinth/modules/upgrades/templates/update-firstboot.html index 3c68a0f89..9f3b6e717 100644 --- a/plinth/modules/upgrades/templates/update-firstboot.html +++ b/plinth/modules/upgrades/templates/update-firstboot.html @@ -18,10 +18,9 @@

{% blocktrans trimmed %} - This may take a long time to complete. During an update, - you cannot install apps. Also, this web interface may be temporarily - unavailable and show an error. In that case, refresh the page to - continue. + This may take a long time to complete. During + an update, this web interface may be temporarily unavailable and + show an error. In that case, refresh the page to continue. {% endblocktrans %}

diff --git a/plinth/modules/upgrades/urls.py b/plinth/modules/upgrades/urls.py index 625485d83..e20c2b147 100644 --- a/plinth/modules/upgrades/urls.py +++ b/plinth/modules/upgrades/urls.py @@ -16,5 +16,8 @@ urlpatterns = [ views.BackportsFirstbootView.as_view(), name='backports-firstboot'), url(r'^sys/upgrades/firstboot/update/$', views.UpdateFirstbootView.as_view(), name='update-firstboot'), + url(r'^sys/upgrades/firstboot/update/progress/$', + views.UpdateFirstbootProgressView.as_view(), + name='update-firstboot-progress'), url(r'^sys/upgrades/upgrade/$', views.upgrade, name='upgrade'), ] diff --git a/plinth/modules/upgrades/views.py b/plinth/modules/upgrades/views.py index a7dfe68b1..fc7d42a23 100644 --- a/plinth/modules/upgrades/views.py +++ b/plinth/modules/upgrades/views.py @@ -10,6 +10,7 @@ from django.http import HttpResponseRedirect from django.shortcuts import redirect from django.urls import reverse_lazy from django.utils.translation import ugettext as _ +from django.views.generic import TemplateView from django.views.generic.edit import FormView from plinth import __version__, actions, package @@ -179,14 +180,35 @@ class UpdateFirstbootView(FormView): template_name = 'update-firstboot.html' form_class = UpdateFirstbootForm + def __init__(self): + """Define instance attribute.""" + self.update = True + def get_success_url(self): """Return next firstboot step.""" + if self.update: + return reverse_lazy('upgrades:update-firstboot-progress') + return reverse_lazy(first_boot.next_step()) def form_valid(self, form): """Run update if selected, and mark step as done.""" - if form.cleaned_data['update_now']: + self.update = form.cleaned_data['update_now'] + if self.update: actions.superuser_run('upgrades', ['run']) first_boot.mark_step_done('initial_update') return super().form_valid(form) + + +class UpdateFirstbootProgressView(TemplateView): + """View to show initial update progress.""" + template_name = 'update-firstboot-progress.html' + + def get_context_data(self, *args, **kwargs): + context = super().get_context_data(*args, **kwargs) + context['is_busy'] = (_is_updating() + or package.is_package_manager_busy()) + context['next_step'] = first_boot.next_step() + context['refresh_page_sec'] = 3 if context['is_busy'] else None + return context