*: Use privileged decorator for package actions

Tests:

- DONE: Check if package manager is busy works
  - DONE: Power app shows status in app/restart/shutdown pages
  - DONE: Upgrades app shows in app page and first boot wizard page
  - DONE: When attempting force upgrade, busy state results in a back-off
- DONE: An app's packages can be installed/uninstalled successfully
  - DONE: apt update is run before install
  - DONE: If network is not available during package install, error message is shown
- DONE: Filtering packages with configuration file prompts works. Tested with
  firewall 1.0.3 to 1.2.1.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa authored and James Valleroy committed 2022-10-08 18:54:00 -04:00
1 parent 9a4905e832
commit 0bda4843a7
6 files changed
+91 -175

No files matched your search

+6 -3
View File
@@ -22,7 +22,8 @@ class PowerAppView(AppView):
def get_context_data(self, *args, **kwargs):
"""Add additional context data for template."""
context = super().get_context_data(*args, **kwargs)
context['pkg_manager_is_busy'] = package.is_package_manager_busy()
is_busy = package.is_package_manager_busy()
context['pkg_manager_is_busy'] = is_busy
return context
@@ -36,12 +37,13 @@ def restart(request):
app = app_module.App.get('power')
form = Form(prefix='power')
is_busy = package.is_package_manager_busy()
return TemplateResponse(
request, 'power_restart.html', {
'title': app.info.name,
'form': form,
'manual_page': app.info.manual_page,
'pkg_manager_is_busy': package.is_package_manager_busy()
'pkg_manager_is_busy': is_busy
})
@@ -55,10 +57,11 @@ def shutdown(request):
app = app_module.App.get('power')
form = Form(prefix='power')
is_busy = package.is_package_manager_busy()
return TemplateResponse(
request, 'power_shutdown.html', {
'title': app.info.name,
'form': form,
'manual_page': app.info.manual_page,
'pkg_manager_is_busy': package.is_package_manager_busy()
'pkg_manager_is_busy': is_busy
})
+4 -3
View File
@@ -12,8 +12,9 @@ from django.utils.translation import gettext as _
from django.views.generic import TemplateView
from django.views.generic.edit import FormView
from plinth import __version__, package
from plinth import __version__
from plinth.modules import first_boot, upgrades
from plinth.privileged import packages as packages_privileged
from plinth.views import AppView
from . import privileged
@@ -41,7 +42,7 @@ class UpgradesConfigurationView(AppView):
context['can_activate_backports'] = upgrades.can_activate_backports()
context['is_backports_requested'] = upgrades.is_backports_requested()
context['is_busy'] = (_is_updating()
or package.is_package_manager_busy())
or packages_privileged.is_package_manager_busy())
context['log'] = privileged.get_log()
context['refresh_page_sec'] = 3 if context['is_busy'] else None
context['version'] = __version__
@@ -210,7 +211,7 @@ class UpdateFirstbootProgressView(TemplateView):
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())
or packages_privileged.is_package_manager_busy())
context['next_step'] = first_boot.next_step()
context['refresh_page_sec'] = 3 if context['is_busy'] else None
return context