From 3a9c4128ff6b68e1ec5bb2baf9ee544d6eb4ca19 Mon Sep 17 00:00:00 2001 From: Johannes Keyser Date: Sun, 15 Apr 2018 23:37:39 +0200 Subject: [PATCH] setup: disable install button for currently unavailable apps - Fixes #1229. Signed-off-by: Johannes Keyser Reviewed-by: James Valleroy --- plinth/setup.py | 10 ++++++++++ plinth/templates/setup.html | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/plinth/setup.py b/plinth/setup.py index e3324d18b..51c1ec2ce 100644 --- a/plinth/setup.py +++ b/plinth/setup.py @@ -143,6 +143,8 @@ 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' @@ -166,6 +168,14 @@ class Helper(object): 'setup_version': version }) + def list_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 + def init(module_name, module): """Create a setup helper for a module for later use.""" diff --git a/plinth/templates/setup.html b/plinth/templates/setup.html index 4eaf4e92e..a5c7eeb03 100644 --- a/plinth/templates/setup.html +++ b/plinth/templates/setup.html @@ -72,13 +72,22 @@ Please wait for a few moments before trying again. {% endblocktrans %} + {% elif setup_helper.get_state == 'unavailable' %} + {% endif %} +