mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
refactor app
This commit is contained in:
parent
f07df107a9
commit
dddd4370cf
@ -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")
|
||||
|
@ -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',
|
||||
])
|
||||
],
|
||||
},
|
||||
|
@ -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):
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
import logging
|
||||
|
||||
import plugins.plugin as plugin
|
||||
import plugin.plugin as plugin
|
||||
|
||||
|
||||
logger = logging.getLogger("inventree")
|
@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""sample implementation for ActionPlugin"""
|
||||
from plugins.action import ActionPlugin
|
||||
from plugin.action import ActionPlugin
|
||||
|
||||
|
||||
class SimpleActionPlugin(ActionPlugin):
|
@ -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):
|
@ -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")
|
@ -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)
|
0
InvenTree/plugin/samples/integration/__init__.py
Normal file
0
InvenTree/plugin/samples/integration/__init__.py
Normal file
@ -1,5 +1,5 @@
|
||||
"""sample implementation for IntegrationPlugin"""
|
||||
from plugins.integration import IntegrationPluginBase, UrlsMixin
|
||||
from plugin.integration import IntegrationPluginBase, UrlsMixin
|
||||
|
||||
|
||||
class NoIntegrationPlugin(IntegrationPluginBase):
|
@ -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 _
|
@ -2,7 +2,7 @@
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from plugins.action import ActionPlugin
|
||||
from plugin.action import ActionPlugin
|
||||
|
||||
|
||||
class ActionPluginTests(TestCase):
|
@ -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:
|
@ -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
|
||||
|
||||
|
0
plugins/__init__.py
Normal file
0
plugins/__init__.py
Normal file
Loading…
Reference in New Issue
Block a user