mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
remove InvenTreePluginBase
This commit is contained in:
parent
05839ca94c
commit
01e8b5dce3
@ -257,9 +257,9 @@ class BaseInvenTreeSetting(models.Model):
|
||||
plugin = kwargs.get('plugin', None)
|
||||
|
||||
if plugin is not None:
|
||||
from plugin import InvenTreePluginBase
|
||||
from plugin import IntegrationPluginBase
|
||||
|
||||
if issubclass(plugin.__class__, InvenTreePluginBase):
|
||||
if issubclass(plugin.__class__, IntegrationPluginBase):
|
||||
plugin = plugin.plugin_config()
|
||||
|
||||
filters['plugin'] = plugin
|
||||
|
@ -3,14 +3,13 @@ Utility file to enable simper imports
|
||||
"""
|
||||
|
||||
from .registry import registry
|
||||
from .plugin import InvenTreePluginBase, IntegrationPluginBase
|
||||
from .plugin import IntegrationPluginBase
|
||||
from .helpers import MixinNotImplementedError, MixinImplementationError
|
||||
|
||||
__all__ = [
|
||||
'registry',
|
||||
|
||||
'IntegrationPluginBase',
|
||||
'InvenTreePluginBase',
|
||||
'MixinNotImplementedError',
|
||||
'MixinImplementationError',
|
||||
]
|
||||
|
@ -11,7 +11,7 @@ from django.contrib.auth.models import User
|
||||
|
||||
import common.models
|
||||
|
||||
from plugin import InvenTreePluginBase, registry
|
||||
from plugin import IntegrationPluginBase, registry
|
||||
|
||||
|
||||
class PluginConfig(models.Model):
|
||||
@ -135,7 +135,7 @@ class PluginSetting(common.models.GenericReferencedSettingClass, common.models.B
|
||||
|
||||
if plugin:
|
||||
|
||||
if issubclass(plugin.__class__, InvenTreePluginBase):
|
||||
if issubclass(plugin.__class__, IntegrationPluginBase):
|
||||
plugin = plugin.plugin_config()
|
||||
|
||||
kwargs['settings'] = registry.mixins_settings.get(plugin.key, {})
|
||||
|
@ -9,36 +9,10 @@ from django.test import TestCase
|
||||
from plugin.samples.integration.sample import SampleIntegrationPlugin
|
||||
from plugin.samples.integration.another_sample import WrongIntegrationPlugin, NoIntegrationPlugin
|
||||
import plugin.templatetags.plugin_extras as plugin_tags
|
||||
from plugin import registry, InvenTreePluginBase
|
||||
from plugin import registry, IntegrationPluginBase
|
||||
from plugin.plugin import IntegrationPluginBase
|
||||
|
||||
|
||||
class InvenTreePluginTests(TestCase):
|
||||
""" Tests for InvenTreePlugin """
|
||||
def setUp(self):
|
||||
self.plugin = InvenTreePluginBase()
|
||||
|
||||
class NamedPlugin(InvenTreePluginBase):
|
||||
"""a named plugin"""
|
||||
PLUGIN_NAME = 'abc123'
|
||||
|
||||
self.named_plugin = NamedPlugin()
|
||||
|
||||
def test_basic_plugin_init(self):
|
||||
"""check if a basic plugin intis"""
|
||||
self.assertEqual(self.plugin.PLUGIN_NAME, '')
|
||||
self.assertEqual(self.plugin.plugin_name(), '')
|
||||
|
||||
def test_basic_plugin_name(self):
|
||||
"""check if the name of a basic plugin can be set"""
|
||||
self.assertEqual(self.named_plugin.PLUGIN_NAME, 'abc123')
|
||||
self.assertEqual(self.named_plugin.plugin_name(), 'abc123')
|
||||
|
||||
def test_basic_is_active(self):
|
||||
"""check if a basic plugin is active"""
|
||||
self.assertEqual(self.plugin.is_active(), False)
|
||||
|
||||
|
||||
class PluginTagTests(TestCase):
|
||||
""" Tests for the plugin extras """
|
||||
|
||||
@ -90,6 +64,12 @@ class IntegrationPluginBaseTests(TestCase):
|
||||
def setUp(self):
|
||||
self.plugin = IntegrationPluginBase()
|
||||
|
||||
class NamedPlugin(IntegrationPluginBase):
|
||||
"""a named plugin"""
|
||||
PLUGIN_NAME = 'abc123'
|
||||
|
||||
self.named_plugin = NamedPlugin()
|
||||
|
||||
class SimpeIntegrationPluginBase(IntegrationPluginBase):
|
||||
PLUGIN_NAME = 'SimplePlugin'
|
||||
|
||||
@ -109,6 +89,20 @@ class IntegrationPluginBaseTests(TestCase):
|
||||
self.plugin_name = NameIntegrationPluginBase()
|
||||
self.plugin_sample = SampleIntegrationPlugin()
|
||||
|
||||
def test_basic_plugin_init(self):
|
||||
"""check if a basic plugin intis"""
|
||||
self.assertEqual(self.plugin.PLUGIN_NAME, '')
|
||||
self.assertEqual(self.plugin.plugin_name(), '')
|
||||
|
||||
def test_basic_plugin_name(self):
|
||||
"""check if the name of a basic plugin can be set"""
|
||||
self.assertEqual(self.named_plugin.PLUGIN_NAME, 'abc123')
|
||||
self.assertEqual(self.named_plugin.plugin_name(), 'abc123')
|
||||
|
||||
def test_basic_is_active(self):
|
||||
"""check if a basic plugin is active"""
|
||||
self.assertEqual(self.plugin.is_active(), False)
|
||||
|
||||
def test_action_name(self):
|
||||
"""check the name definition possibilities"""
|
||||
# plugin_name
|
||||
|
Loading…
Reference in New Issue
Block a user