refactor sign_color to property

This commit is contained in:
Matthias 2021-09-23 01:13:40 +02:00
parent 3ac3004cd0
commit 261537dc43
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076
2 changed files with 16 additions and 9 deletions

View File

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

View File

@ -37,20 +37,15 @@
<td><span class='fas fa-envelope'></span></td>
<td>{% trans "Commit Message" %}</td><td>{{ plugin.commit.message }}{% include "clip.html" %}</td>
</tr>
{% if plugin.sign_state == 0 %}
{% define 'success' as sign_color %}
{% else %}
{% define 'danger' as sign_color %}
{% endif %}
<tr>
<td><span class='text-{{sign_color}} fas fa-check'></span></td>
<td><span class='text-{{plugin.sign_color}} fas fa-check'></span></td>
<td>{% trans "Commit verified" %}</td>
<td class="bg-{{sign_color}}">{{ plugin.commit.verified }}</td>
<td class="bg-{{plugin.sign_color}}">{{ plugin.commit.verified }}</td>
</tr>
<tr>
<td><span class='text-{{sign_color}} fas fa-key'></span></td>
<td><span class='text-{{plugin.sign_color}} fas fa-key'></span></td>
<td>{% trans "Commit Sign Key" %}</td>
<td class="bg-{{sign_color}}">{{ plugin.commit.key }}{% include "clip.html" %}</td>
<td class="bg-{{plugin.sign_color}}">{{ plugin.commit.key }}{% include "clip.html" %}</td>
</tr>
</table>
</div>