From 24421ee814f266a19a96159e74cb28d18b91571a Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 23 Sep 2021 23:52:19 +0200 Subject: [PATCH] refactor of sign state set function --- InvenTree/plugins/integration/integration.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/InvenTree/plugins/integration/integration.py b/InvenTree/plugins/integration/integration.py index afb860b31e..abb9e7b0e3 100644 --- a/InvenTree/plugins/integration/integration.py +++ b/InvenTree/plugins/integration/integration.py @@ -179,8 +179,6 @@ class IntegrationPlugin(MixinBase, plugin.InvenTreePlugin): def __init__(self): self.add_mixin('base') - self.commit = self.get_plugin_commit() - self.sign_state = 0 self.set_sign_values() def mixin(self, key): @@ -197,11 +195,18 @@ class IntegrationPlugin(MixinBase, plugin.InvenTreePlugin): return get_git_log(path) def set_sign_values(self): - if self.sign_state == 0: + # fetch git log + commit = self.get_plugin_commit() + # resolve state + sign_state = getattr(GitStatus, commit['verified'], GitStatus.E) + + # set variables + self.commit = commit + self.sign_state = sign_state + + if sign_state.status == 0: self.sign_color = 'success' - - elif self.sign_state == 1: + elif sign_state.status == 1: self.sign_color = 'warning' - else: self.sign_color = 'danger'