diff --git a/plinth/modules/upgrades/templates/upgrades.html b/plinth/modules/upgrades/templates/upgrades.html deleted file mode 100644 index 8411e025b..000000000 --- a/plinth/modules/upgrades/templates/upgrades.html +++ /dev/null @@ -1,74 +0,0 @@ -{% extends 'base.html' %} -{% comment %} -# SPDX-License-Identifier: AGPL-3.0-or-later -{% endcomment %} - -{% load i18n %} -{% load static %} - -{% block page_head %} - - {% if is_busy %} - - {% endif %} - -{% endblock %} - - -{% block content %} - -

{{ title }}

- - {% if not is_busy %} -

-

- {% csrf_token %} - - -
-

- {% endif %} - - {% if is_busy %} - - {% endif %} - -

- {% 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. - {% endblocktrans %} -

- - {% if log %} -

- - -

-
{{ log }}
-
-

- {% endif %} - -{% endblock %} - -{% block page_js %} - - {% if is_busy %} - - {% endif %} -{% endblock %} diff --git a/plinth/modules/upgrades/templates/upgrades_configure.html b/plinth/modules/upgrades/templates/upgrades_configure.html index 3533410e9..f2ef8ea33 100644 --- a/plinth/modules/upgrades/templates/upgrades_configure.html +++ b/plinth/modules/upgrades/templates/upgrades_configure.html @@ -5,10 +5,63 @@ {% load bootstrap %} {% load i18n %} +{% load static %} -{% block status %} - - {% trans 'Manual update' %} - +{% block page_head %} + {% if is_busy %} + + {% endif %} +{% endblock %} + +{% block extra_content %} +

{% trans "Manual update" %}

+ {% if is_busy %} +

+ +

+ {% else %} +

+

+ {% csrf_token %} + +
+

+ {% endif %} + +

+ {% 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. + {% endblocktrans %} +

+ + {% if log %} +

+ + +

+
{{ log }}
+
+

+ {% endif %} +{% endblock %} + +{% block page_js %} + {% if is_busy %} + + {% endif %} {% endblock %} diff --git a/plinth/modules/upgrades/views.py b/plinth/modules/upgrades/views.py index 4e0549f2c..8413df8aa 100644 --- a/plinth/modules/upgrades/views.py +++ b/plinth/modules/upgrades/views.py @@ -4,7 +4,7 @@ FreedomBox app for upgrades. """ from django.contrib import messages -from django.template.response import TemplateResponse +from django.shortcuts import redirect from django.urls import reverse_lazy from django.utils.translation import ugettext as _ @@ -26,6 +26,12 @@ class UpgradesConfigurationView(AppView): def get_initial(self): return {'auto_upgrades_enabled': upgrades.is_enabled()} + def get_context_data(self, *args, **kwargs): + context = super().get_context_data(*args, **kwargs) + context['is_busy'] = package.is_package_manager_busy() + context['log'] = get_log() + return context + def form_valid(self, form): """Apply the form changes.""" old_status = form.initial @@ -62,18 +68,11 @@ def get_log(): def upgrade(request): """Serve the upgrade page.""" - is_busy = package.is_package_manager_busy() - if request.method == 'POST': try: actions.superuser_run('upgrades', ['run']) messages.success(request, _('Upgrade process started.')) - is_busy = True except ActionError: messages.error(request, _('Starting upgrade failed.')) - return TemplateResponse(request, 'upgrades.html', { - 'title': _('Manual update'), - 'is_busy': is_busy, - 'log': get_log() - }) + return redirect(reverse_lazy('upgrades:index')) diff --git a/plinth/templates/app.html b/plinth/templates/app.html index 21eb4d50d..b24f817e6 100644 --- a/plinth/templates/app.html +++ b/plinth/templates/app.html @@ -56,4 +56,7 @@ {% endif %} {% endblock %} + {% block extra_content %} + {% endblock %} + {% endblock %}