From 70b568d579a9fa58952e3d02a334b759f38569ed Mon Sep 17 00:00:00 2001 From: Joseph Nuthalapati Date: Tue, 15 May 2018 16:26:55 +0530 Subject: [PATCH] setup: Remove unavailable as a state in setup_helper - Unavailable being a state can cause issues in several places in the where there are currently only checks for 'needs-setup' - Since it's only used in the UI, a method to check whether a module is unavailable should be sufficient. Signed-off-by: Joseph Nuthalapati Reviewed-by: James Valleroy --- plinth/setup.py | 15 ++++++--------- plinth/templates/setup.html | 12 ++++++------ 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/plinth/setup.py b/plinth/setup.py index 51c1ec2ce..5e9156f16 100644 --- a/plinth/setup.py +++ b/plinth/setup.py @@ -143,8 +143,6 @@ class Helper(object): return 'up-to-date' if not current_version: - if any(self.list_unavailable_packages()): - return 'unavailable' return 'needs-setup' else: return 'needs-update' @@ -164,17 +162,16 @@ class Helper(object): """Set a module's setup version.""" from . import models - models.Module.objects.update_or_create(pk=self.module_name, defaults={ - 'setup_version': version - }) + models.Module.objects.update_or_create( + pk=self.module_name, defaults={'setup_version': version}) - def list_unavailable_packages(self): + def has_unavailable_packages(self): """List the unavailable packages managed by the module (if any).""" cache = apt.Cache() managed_pkgs = getattr(self.module, 'managed_packages', []) - unavailable_pkgs = [pkg_name for pkg_name in managed_pkgs - if pkg_name not in cache] - return unavailable_pkgs + unavailable_pkgs = (pkg_name for pkg_name in managed_pkgs + if pkg_name not in cache) + return any(unavailable_pkgs) def init(module_name, module): diff --git a/plinth/templates/setup.html b/plinth/templates/setup.html index a5c7eeb03..9d79bce43 100644 --- a/plinth/templates/setup.html +++ b/plinth/templates/setup.html @@ -72,22 +72,22 @@ Please wait for a few moments before trying again. {% endblocktrans %} - {% elif setup_helper.get_state == 'unavailable' %} + {% elif setup_helper.has_unavailable_packages %} {% endif %}