diff --git a/InvenTree/InvenTree/api.py b/InvenTree/InvenTree/api.py index a006050694..e53a8b96cb 100644 --- a/InvenTree/InvenTree/api.py +++ b/InvenTree/InvenTree/api.py @@ -21,7 +21,7 @@ from .views import AjaxView from .version import inventreeVersion, inventreeApiVersion, inventreeInstanceName from .status import is_worker_running -from plugins import plugins as inventree_plugins +from plugin import plugins as inventree_plugins logger = logging.getLogger("inventree") diff --git a/InvenTree/InvenTree/settings.py b/InvenTree/InvenTree/settings.py index bd69fafc93..baed15afa2 100644 --- a/InvenTree/InvenTree/settings.py +++ b/InvenTree/InvenTree/settings.py @@ -27,7 +27,7 @@ import yaml from django.utils.translation import gettext_lazy as _ from django.contrib.messages import constants as messages -from plugins import plugins as inventree_plugins +from plugin import plugins as inventree_plugins def _is_true(x): @@ -337,7 +337,7 @@ TEMPLATES = [ 'django.template.loaders.cached.Loader', [ 'django.template.loaders.app_directories.Loader', 'django.template.loaders.filesystem.Loader', - 'plugins.loader.PluginTemplateLoader', + 'plugin.loader.PluginTemplateLoader', ]) ], }, diff --git a/InvenTree/barcodes/api.py b/InvenTree/barcodes/api.py index dd596de794..38041096ab 100644 --- a/InvenTree/barcodes/api.py +++ b/InvenTree/barcodes/api.py @@ -13,7 +13,7 @@ from stock.models import StockItem from stock.serializers import StockItemSerializer from barcodes.barcode import hash_barcode -from plugins.plugins import load_barcode_plugins +from plugin.plugins import load_barcode_plugins class BarcodeScan(APIView): diff --git a/InvenTree/plugins/__init__.py b/InvenTree/plugin/__init__.py similarity index 100% rename from InvenTree/plugins/__init__.py rename to InvenTree/plugin/__init__.py diff --git a/InvenTree/plugins/action.py b/InvenTree/plugin/action.py similarity index 97% rename from InvenTree/plugins/action.py rename to InvenTree/plugin/action.py index cc2872b6d2..5e36c22e74 100644 --- a/InvenTree/plugins/action.py +++ b/InvenTree/plugin/action.py @@ -3,7 +3,7 @@ import logging -import plugins.plugin as plugin +import plugin.plugin as plugin logger = logging.getLogger("inventree") diff --git a/InvenTree/plugins/samples/__init__.py b/InvenTree/plugin/builtin/__init__.py similarity index 100% rename from InvenTree/plugins/samples/__init__.py rename to InvenTree/plugin/builtin/__init__.py diff --git a/InvenTree/plugins/samples/action/__init__.py b/InvenTree/plugin/builtin/action/__init__.py similarity index 100% rename from InvenTree/plugins/samples/action/__init__.py rename to InvenTree/plugin/builtin/action/__init__.py diff --git a/InvenTree/plugins/samples/action/simpleactionplugin.py b/InvenTree/plugin/builtin/action/simpleactionplugin.py similarity index 93% rename from InvenTree/plugins/samples/action/simpleactionplugin.py rename to InvenTree/plugin/builtin/action/simpleactionplugin.py index def8aada8b..01a0829887 100644 --- a/InvenTree/plugins/samples/action/simpleactionplugin.py +++ b/InvenTree/plugin/builtin/action/simpleactionplugin.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """sample implementation for ActionPlugin""" -from plugins.action import ActionPlugin +from plugin.action import ActionPlugin class SimpleActionPlugin(ActionPlugin): diff --git a/InvenTree/plugins/samples/action/test_samples_action.py b/InvenTree/plugin/builtin/action/test_samples_action.py similarity index 94% rename from InvenTree/plugins/samples/action/test_samples_action.py rename to InvenTree/plugin/builtin/action/test_samples_action.py index 595c3fa948..6406810894 100644 --- a/InvenTree/plugins/samples/action/test_samples_action.py +++ b/InvenTree/plugin/builtin/action/test_samples_action.py @@ -3,7 +3,7 @@ from django.test import TestCase from django.contrib.auth import get_user_model -from plugins.samples.action.simpleactionplugin import SimpleActionPlugin +from plugin.builtin.action.simpleactionplugin import SimpleActionPlugin class SimpleActionPluginTests(TestCase): diff --git a/InvenTree/plugins/integration.py b/InvenTree/plugin/integration.py similarity index 99% rename from InvenTree/plugins/integration.py rename to InvenTree/plugin/integration.py index b55efb732a..c47a6ba060 100644 --- a/InvenTree/plugins/integration.py +++ b/InvenTree/plugin/integration.py @@ -12,7 +12,7 @@ from django.conf import settings from django.utils.text import slugify from django.utils.translation import ugettext_lazy as _ -import plugins.plugin as plugin +import plugin.plugin as plugin logger = logging.getLogger("inventree") diff --git a/InvenTree/plugins/loader.py b/InvenTree/plugin/loader.py similarity index 100% rename from InvenTree/plugins/loader.py rename to InvenTree/plugin/loader.py diff --git a/InvenTree/plugins/plugin.py b/InvenTree/plugin/plugin.py similarity index 100% rename from InvenTree/plugins/plugin.py rename to InvenTree/plugin/plugin.py diff --git a/InvenTree/plugins/plugins.py b/InvenTree/plugin/plugins.py similarity index 82% rename from InvenTree/plugins/plugins.py rename to InvenTree/plugin/plugins.py index 142e22e6a0..0c1981ad59 100644 --- a/InvenTree/plugins/plugins.py +++ b/InvenTree/plugin/plugins.py @@ -7,11 +7,11 @@ import pkgutil import logging # Action plugins -import plugins.samples.action as action -from plugins.action import ActionPlugin +import plugin.builtin.action as action +from plugin.action import ActionPlugin -import plugins.samples.integration as integration -from plugins.integration import IntegrationPluginBase +import plugin.samples.integration as integration +from plugin.integration import IntegrationPluginBase logger = logging.getLogger("inventree") @@ -55,7 +55,7 @@ def get_plugins(pkg, baseclass): return plugins -def load_plugins(name: str, module, cls): +def load_plugins(name: str, cls, module=None): """general function to load a plugin class :param name: name of the plugin for logs @@ -81,14 +81,14 @@ def load_action_plugins(): """ Return a list of all registered action plugins """ - return load_plugins('action', action, ActionPlugin) + return load_plugins('action', ActionPlugin, module=action) def load_integration_plugins(): """ Return a list of all registered integration plugins """ - return load_plugins('integration', integration, IntegrationPluginBase) + return load_plugins('integration', IntegrationPluginBase, module=integration) def load_barcode_plugins(): @@ -98,4 +98,4 @@ def load_barcode_plugins(): from barcodes import plugins as BarcodePlugins from barcodes.barcode import BarcodePlugin - return load_plugins('barcode', BarcodePlugins, BarcodePlugin) + return load_plugins('barcode', BarcodePlugins, module=BarcodePlugin) diff --git a/InvenTree/plugins/samples/integration/__init__.py b/InvenTree/plugin/samples/__init__.py similarity index 100% rename from InvenTree/plugins/samples/integration/__init__.py rename to InvenTree/plugin/samples/__init__.py diff --git a/InvenTree/plugin/samples/integration/__init__.py b/InvenTree/plugin/samples/integration/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/InvenTree/plugins/samples/integration/another_sample.py b/InvenTree/plugin/samples/integration/another_sample.py similarity index 84% rename from InvenTree/plugins/samples/integration/another_sample.py rename to InvenTree/plugin/samples/integration/another_sample.py index 800481dee4..5fe1daf30b 100644 --- a/InvenTree/plugins/samples/integration/another_sample.py +++ b/InvenTree/plugin/samples/integration/another_sample.py @@ -1,5 +1,5 @@ """sample implementation for IntegrationPlugin""" -from plugins.integration import IntegrationPluginBase, UrlsMixin +from plugin.integration import IntegrationPluginBase, UrlsMixin class NoIntegrationPlugin(IntegrationPluginBase): diff --git a/InvenTree/plugins/samples/integration/sample.py b/InvenTree/plugin/samples/integration/sample.py similarity index 92% rename from InvenTree/plugins/samples/integration/sample.py rename to InvenTree/plugin/samples/integration/sample.py index 381d91d1cd..b6be51823d 100644 --- a/InvenTree/plugins/samples/integration/sample.py +++ b/InvenTree/plugin/samples/integration/sample.py @@ -1,5 +1,5 @@ """sample implementations for IntegrationPlugin""" -from plugins.integration import AppMixin, SettingsMixin, UrlsMixin, NavigationMixin, IntegrationPluginBase +from plugin.integration import AppMixin, SettingsMixin, UrlsMixin, NavigationMixin, IntegrationPluginBase from django.http import HttpResponse from django.utils.translation import ugettext_lazy as _ diff --git a/InvenTree/plugins/samples/integration/test_samples_integration.py b/InvenTree/plugin/samples/integration/test_samples_integration.py similarity index 100% rename from InvenTree/plugins/samples/integration/test_samples_integration.py rename to InvenTree/plugin/samples/integration/test_samples_integration.py diff --git a/InvenTree/plugins/test_action.py b/InvenTree/plugin/test_action.py similarity index 98% rename from InvenTree/plugins/test_action.py rename to InvenTree/plugin/test_action.py index fb0b7b5aa4..2a9e4a9a37 100644 --- a/InvenTree/plugins/test_action.py +++ b/InvenTree/plugin/test_action.py @@ -2,7 +2,7 @@ from django.test import TestCase -from plugins.action import ActionPlugin +from plugin.action import ActionPlugin class ActionPluginTests(TestCase): diff --git a/InvenTree/plugins/test_integration.py b/InvenTree/plugin/test_integration.py similarity index 98% rename from InvenTree/plugins/test_integration.py rename to InvenTree/plugin/test_integration.py index b391c81afd..d865af86bd 100644 --- a/InvenTree/plugins/test_integration.py +++ b/InvenTree/plugin/test_integration.py @@ -6,7 +6,7 @@ from django.conf.urls import url, include from datetime import datetime -from plugins.integration import AppMixin, IntegrationPluginBase, SettingsMixin, UrlsMixin, NavigationMixin +from plugin.integration import AppMixin, IntegrationPluginBase, SettingsMixin, UrlsMixin, NavigationMixin class BaseMixinDefinition: diff --git a/InvenTree/plugins/test_plugin.py b/InvenTree/plugin/test_plugin.py similarity index 89% rename from InvenTree/plugins/test_plugin.py rename to InvenTree/plugin/test_plugin.py index aa8aa92cfc..1bf60a0eb3 100644 --- a/InvenTree/plugins/test_plugin.py +++ b/InvenTree/plugin/test_plugin.py @@ -3,11 +3,11 @@ from django.test import TestCase from django.conf import settings -import plugins.plugin -import plugins.integration -from plugins.samples.integration.sample import SampleIntegrationPlugin -from plugins.samples.integration.another_sample import WrongIntegrationPlugin, NoIntegrationPlugin -from plugins.plugins import load_integration_plugins # , load_action_plugins, load_barcode_plugins +import plugin.plugin +import plugin.integration +from plugin.samples.integration.sample import SampleIntegrationPlugin +from plugin.samples.integration.another_sample import WrongIntegrationPlugin, NoIntegrationPlugin +from plugin.plugins import load_integration_plugins # , load_action_plugins, load_barcode_plugins import part.templatetags.plugin_extras as plugin_tags diff --git a/plugins/__init__.py b/plugins/__init__.py new file mode 100644 index 0000000000..e69de29bb2