From 261537dc43c087cf760dde67a39234fd743e98cc Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 23 Sep 2021 01:13:40 +0200 Subject: [PATCH] refactor sign_color to property --- InvenTree/plugins/integration/integration.py | 12 ++++++++++++ .../InvenTree/settings/plugin_settings.html | 13 ++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/InvenTree/plugins/integration/integration.py b/InvenTree/plugins/integration/integration.py index 3fbdf2b015..8a14379c5d 100644 --- a/InvenTree/plugins/integration/integration.py +++ b/InvenTree/plugins/integration/integration.py @@ -164,8 +164,10 @@ 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): return key in self._mixins @@ -179,3 +181,13 @@ class IntegrationPlugin(MixinBase, plugin.InvenTreePlugin): def get_plugin_commit(self): path = inspect.getfile(self.__class__) return get_git_log(path) + + def set_sign_values(self): + if self.sign_state == 0: + self.sign_color = 'success' + + elif self.sign_state == 1: + self.sign_color = 'warning' + + else: + self.sign_color = 'danger' diff --git a/InvenTree/templates/InvenTree/settings/plugin_settings.html b/InvenTree/templates/InvenTree/settings/plugin_settings.html index 7ded0b4a08..803090d63f 100644 --- a/InvenTree/templates/InvenTree/settings/plugin_settings.html +++ b/InvenTree/templates/InvenTree/settings/plugin_settings.html @@ -37,20 +37,15 @@ {% trans "Commit Message" %}{{ plugin.commit.message }}{% include "clip.html" %} - {% if plugin.sign_state == 0 %} - {% define 'success' as sign_color %} - {% else %} - {% define 'danger' as sign_color %} - {% endif %} - + {% trans "Commit verified" %} - {{ plugin.commit.verified }} + {{ plugin.commit.verified }} - + {% trans "Commit Sign Key" %} - {{ plugin.commit.key }}{% include "clip.html" %} + {{ plugin.commit.key }}{% include "clip.html" %}