From 62c6337905e9072882a6828a78db84accbba65b8 Mon Sep 17 00:00:00 2001 From: Jakub Kadlcik Date: Jan 13 2018 16:59:16 +0000 Subject: [frontend] always have a known state of a module --- diff --git a/frontend/coprs_frontend/coprs/models.py b/frontend/coprs_frontend/coprs/models.py index a7ac67f..f180abb 100644 --- a/frontend/coprs_frontend/coprs/models.py +++ b/frontend/coprs_frontend/coprs/models.py @@ -1252,13 +1252,20 @@ class Module(db.Model, helpers.Serializer): return Action.query.filter(Action.object_type == "module").filter(Action.object_id == self.id).first() @property + def status(self): + """ + Return numeric representation of status of this build + """ + if any(b for b in self.builds if b.status == StatusEnum("failed")): + return helpers.ModuleStatusEnum("failed") + return self.action.result if self.action else helpers.ModuleStatusEnum("pending") + + @property def state(self): """ Return text representation of status of this build """ - if self.action is not None: - return helpers.ModuleStatusEnum(self.action.result) - return "-" + return helpers.ModuleStatusEnum(self.status) def repo_url(self, arch): # @TODO Use custom chroot instead of fedora-24 diff --git a/frontend/coprs_frontend/coprs/templates/_helpers.html b/frontend/coprs_frontend/coprs/templates/_helpers.html index bd09f74..4d769e8 100644 --- a/frontend/coprs_frontend/coprs/templates/_helpers.html +++ b/frontend/coprs_frontend/coprs/templates/_helpers.html @@ -135,11 +135,7 @@ {% endmacro %} {% macro module_state(module) %} - {% if module.action %} - {{ build_state_text(module.action.result | module_state_from_num) }} - {% else %} - - - {% endif %} + {{ build_state_text(module.status | module_state_from_num) }} {% endmacro %} {% macro chroot_to_os_logo(chroot) %}