mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
refactor
This commit is contained in:
parent
c085a86891
commit
dd61714435
@ -346,33 +346,32 @@ class IntegrationPluginBase(MixinBase, plugin.InvenTreePlugin):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
# git
|
# git
|
||||||
def get_plugin_commit(self):
|
def get_package_commit(self):
|
||||||
"""get last git commit for plugin"""
|
"""get last git commit for plugin"""
|
||||||
return get_git_log(self.def_path)
|
return get_git_log(self.def_path)
|
||||||
|
|
||||||
def set_package(self):
|
def set_package(self):
|
||||||
"""add the last commit of the plugins class file into plugins context"""
|
"""add packaging info of the plugins into plugins context"""
|
||||||
if self.is_package:
|
if self.is_package:
|
||||||
# is a package - no signing - no commit
|
# is a package - no commit
|
||||||
package = {}
|
package = {}
|
||||||
else:
|
else:
|
||||||
# fetch git log
|
# fetch git commit
|
||||||
package = self.get_plugin_commit()
|
package = self.get_package_commit()
|
||||||
|
|
||||||
# resolve state
|
|
||||||
sign_state = getattr(GitStatus, str(package.get('verified')), GitStatus.N)
|
|
||||||
|
|
||||||
# set variables
|
|
||||||
self.package = package
|
|
||||||
self.sign_state = sign_state
|
|
||||||
|
|
||||||
# process date
|
# process date
|
||||||
if self.package.get('date'):
|
if package.get('date'):
|
||||||
self.package['date'] = datetime.fromisoformat(self.package.get('date'))
|
package['date'] = datetime.fromisoformat(package.get('date'))
|
||||||
|
|
||||||
|
# process sign state
|
||||||
|
sign_state = getattr(GitStatus, str(package.get('verified')), GitStatus.N)
|
||||||
if sign_state.status == 0:
|
if sign_state.status == 0:
|
||||||
self.sign_color = 'success'
|
self.sign_color = 'success'
|
||||||
elif sign_state.status == 1:
|
elif sign_state.status == 1:
|
||||||
self.sign_color = 'warning'
|
self.sign_color = 'warning'
|
||||||
else:
|
else:
|
||||||
self.sign_color = 'danger'
|
self.sign_color = 'danger'
|
||||||
|
|
||||||
|
# set variables
|
||||||
|
self.package = package
|
||||||
|
self.sign_state = sign_state
|
||||||
|
Loading…
Reference in New Issue
Block a user