2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-29 12:06:44 +00:00

move properties to meta

This commit is contained in:
Matthias 2022-05-11 14:45:45 +02:00
parent dfb11cca1d
commit f76dcdeb82
No known key found for this signature in database
GPG Key ID: AB6D0E6C4CB65093

View File

@ -21,14 +21,8 @@ from plugin.helpers import get_git_log, GitStatus
logger = logging.getLogger("inventree") logger = logging.getLogger("inventree")
class InvenTreePluginBase: class MetaBase:
""" """Base class for a plugins metadata"""
Base class for a plugin
DO NOT USE THIS DIRECTLY, USE plugin.IntegrationPluginBase
"""
def __init__(self):
pass
# Override the plugin name for each concrete plugin instance # Override the plugin name for each concrete plugin instance
PLUGIN_NAME = '' PLUGIN_NAME = ''
@ -43,6 +37,13 @@ class InvenTreePluginBase:
""" """
return self.PLUGIN_NAME return self.PLUGIN_NAME
@property
def name(self):
"""
Name of plugin
"""
return self.plugin_name()
def plugin_slug(self): def plugin_slug(self):
""" """
Slug of plugin Slug of plugin
@ -56,6 +57,13 @@ class InvenTreePluginBase:
return slugify(slug.lower()) return slugify(slug.lower())
@property
def slug(self):
"""
Slug of plugin
"""
return self.plugin_slug()
def plugin_title(self): def plugin_title(self):
""" """
Title of plugin Title of plugin
@ -66,6 +74,13 @@ class InvenTreePluginBase:
else: else:
return self.plugin_name() return self.plugin_name()
@property
def human_name(self):
"""
Human readable name of plugin
"""
return self.plugin_title()
def plugin_config(self): def plugin_config(self):
""" """
Return the PluginConfig object associated with this plugin Return the PluginConfig object associated with this plugin
@ -143,7 +158,7 @@ class MixinBase:
return mixins return mixins
class InvenTreePlugin(MixinBase, InvenTreePluginBase): class InvenTreePlugin(MixinBase, MetaBase):
""" """
The InvenTreePlugin class is used to integrate with 3rd party software The InvenTreePlugin class is used to integrate with 3rd party software
@ -181,27 +196,6 @@ class InvenTreePlugin(MixinBase, InvenTreePluginBase):
return path.startswith('plugin/samples/') return path.startswith('plugin/samples/')
# region properties # region properties
@property
def slug(self):
"""
Slug of plugin
"""
return self.plugin_slug()
@property
def name(self):
"""
Name of plugin
"""
return self.plugin_name()
@property
def human_name(self):
"""
Human readable name of plugin
"""
return self.plugin_title()
@property @property
def description(self): def description(self):
""" """