mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
remove old loading mechanism
This commit is contained in:
parent
8088bf28fe
commit
bcb0f62e42
@ -5,8 +5,6 @@ Main JSON interface views
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.http import JsonResponse
|
||||
|
||||
@ -21,15 +19,7 @@ from .views import AjaxView
|
||||
from .version import inventreeVersion, inventreeApiVersion, inventreeInstanceName
|
||||
from .status import is_worker_running
|
||||
|
||||
from plugin.plugins import load_action_plugins
|
||||
|
||||
|
||||
logger = logging.getLogger("inventree")
|
||||
|
||||
|
||||
logger.info("Loading action plugins...")
|
||||
action_plugins = load_action_plugins()
|
||||
|
||||
from plugin import plugin_registry
|
||||
|
||||
class InfoView(AjaxView):
|
||||
""" Simple JSON endpoint for InvenTree information.
|
||||
@ -110,10 +100,11 @@ class ActionPluginView(APIView):
|
||||
'error': _("No action specified")
|
||||
})
|
||||
|
||||
action_plugins = plugin_registry.with_mixin('action')
|
||||
for plugin_class in action_plugins:
|
||||
if plugin_class.action_name() == action:
|
||||
|
||||
plugin = plugin_class(request.user, data=data)
|
||||
# TODO @matmair use easier syntax once InvenTree 0.7.0 is released
|
||||
plugin = plugin_class.init(request.user, data=data)
|
||||
|
||||
plugin.perform_action()
|
||||
|
||||
|
@ -8,10 +8,6 @@ import logging
|
||||
|
||||
from django.core.exceptions import AppRegistryNotReady
|
||||
|
||||
# Action plugins
|
||||
import plugin.builtin.action as action
|
||||
from plugin.action import ActionPlugin
|
||||
|
||||
|
||||
logger = logging.getLogger("inventree")
|
||||
|
||||
@ -97,13 +93,6 @@ def load_plugins(name: str, cls, module):
|
||||
return plugins
|
||||
|
||||
|
||||
def load_action_plugins():
|
||||
"""
|
||||
Return a list of all registered action plugins
|
||||
"""
|
||||
return load_plugins('action', ActionPlugin, action)
|
||||
|
||||
|
||||
def load_barcode_plugins():
|
||||
"""
|
||||
Return a list of all registered barcode plugins
|
||||
|
@ -183,7 +183,17 @@ class PluginsRegistry:
|
||||
# Log collected plugins
|
||||
logger.info(f'Collected {len(self.plugin_modules)} plugins!')
|
||||
logger.info(", ".join([a.__module__ for a in self.plugin_modules]))
|
||||
def with_mixin(self, mixin: str):
|
||||
"""
|
||||
Returns reference to all plugins that have a specified mixin enabled
|
||||
"""
|
||||
result = []
|
||||
|
||||
for plugin in self.plugins.items():
|
||||
if plugin.mixin_enabled(mixin):
|
||||
result.append(plugin)
|
||||
|
||||
return result
|
||||
def _init_plugins(self, disabled=None):
|
||||
"""
|
||||
Initialise all found plugins
|
||||
|
Loading…
Reference in New Issue
Block a user