refactor of sign state set function

This commit is contained in:
Matthias 2021-09-23 23:52:19 +02:00
parent 8285bfe1a3
commit 24421ee814
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076

View File

@ -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'