mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-03-11 09:04:54 +00:00
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 <njoseph@thoughtworks.com> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
0587d1c2b7
commit
70b568d579
@ -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):
|
||||
|
||||
@ -72,22 +72,22 @@
|
||||
Please wait for a few moments before trying again.
|
||||
{% endblocktrans %}
|
||||
</div>
|
||||
{% elif setup_helper.get_state == 'unavailable' %}
|
||||
{% elif setup_helper.has_unavailable_packages %}
|
||||
<div class="alert alert-warning" role="alert">
|
||||
{% blocktrans trimmed %}
|
||||
This application is currently unavailable in your distribution.
|
||||
{% endblocktrans %}
|
||||
This application is currently not available in your distribution.
|
||||
{% endblocktrans %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<input type="submit" class="btn btn-md btn-primary"
|
||||
{{ package_manager_is_busy|yesno:'disabled="disabled"' }}
|
||||
{% if package_manager_is_busy or setup_helper.has_unavailable_packages %}
|
||||
disabled="disabled"
|
||||
{% endif %}
|
||||
{% if setup_helper.get_state == 'needs-setup' %}
|
||||
value="{% trans "Install" %}"
|
||||
{% elif setup_helper.get_state == 'needs-upgrade' %}
|
||||
value="{% trans "Update" %}"
|
||||
{% elif setup_helper.get_state == 'unavailable' %}
|
||||
value="{% trans "Install" %}" disabled="disabled"
|
||||
{% endif %} />
|
||||
|
||||
</form>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user