mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-30 20:55:42 +00:00 
			
		
		
		
	remove legacy action
This commit is contained in:
		| @@ -3,16 +3,12 @@ Utility file to enable simper imports | ||||
| """ | ||||
|  | ||||
| from .registry import registry | ||||
|  | ||||
| from .plugin import InvenTreePluginBase, IntegrationPluginBase | ||||
| from .base.action.action import ActionPlugin | ||||
|  | ||||
| from .helpers import MixinNotImplementedError, MixinImplementationError | ||||
|  | ||||
| __all__ = [ | ||||
|     'registry', | ||||
|  | ||||
|     'ActionPlugin', | ||||
|     'IntegrationPluginBase', | ||||
|     'InvenTreePluginBase', | ||||
|     'MixinNotImplementedError', | ||||
|   | ||||
| @@ -1,23 +0,0 @@ | ||||
| # -*- coding: utf-8 -*- | ||||
| """Class for ActionPlugin""" | ||||
|  | ||||
| import logging | ||||
| import warnings | ||||
|  | ||||
| from plugin.base.action.mixins import ActionMixin | ||||
| import plugin.plugin | ||||
|  | ||||
|  | ||||
| logger = logging.getLogger("inventree") | ||||
|  | ||||
|  | ||||
| class ActionPlugin(ActionMixin, plugin.plugin.IntegrationPluginBase): | ||||
|     """ | ||||
|     Legacy action definition - will be replaced | ||||
|     Please use the new Integration Plugin API and the Action mixin | ||||
|     """ | ||||
|     # TODO @matmair remove this with InvenTree 0.7.0 | ||||
|     def __init__(self, user=None, data=None): | ||||
|         warnings.warn("using the ActionPlugin is depreceated", DeprecationWarning) | ||||
|         super().__init__() | ||||
|         self.init(user, data) | ||||
| @@ -2,32 +2,35 @@ | ||||
|  | ||||
| from django.test import TestCase | ||||
|  | ||||
| from plugin.base.action.action import ActionPlugin | ||||
| from plugin import IntegrationPluginBase | ||||
| from plugin.mixins import ActionMixin | ||||
|  | ||||
|  | ||||
| class ActionPluginTests(TestCase): | ||||
|     """ Tests for ActionPlugin """ | ||||
| class ActionMixinTests(TestCase): | ||||
|     """ Tests for ActionMixin """ | ||||
|     ACTION_RETURN = 'a action was performed' | ||||
|  | ||||
|     def setUp(self): | ||||
|         self.plugin = ActionPlugin('user') | ||||
|         class SimplePlugin(ActionMixin, IntegrationPluginBase): | ||||
|             pass | ||||
|         self.plugin = SimplePlugin('user') | ||||
|  | ||||
|         class TestActionPlugin(ActionPlugin): | ||||
|         class TestActionPlugin(ActionMixin, IntegrationPluginBase): | ||||
|             """a action plugin""" | ||||
|             ACTION_NAME = 'abc123' | ||||
|  | ||||
|             def perform_action(self): | ||||
|                 return ActionPluginTests.ACTION_RETURN + 'action' | ||||
|                 return ActionMixinTests.ACTION_RETURN + 'action' | ||||
|  | ||||
|             def get_result(self): | ||||
|                 return ActionPluginTests.ACTION_RETURN + 'result' | ||||
|                 return ActionMixinTests.ACTION_RETURN + 'result' | ||||
|  | ||||
|             def get_info(self): | ||||
|                 return ActionPluginTests.ACTION_RETURN + 'info' | ||||
|                 return ActionMixinTests.ACTION_RETURN + 'info' | ||||
|  | ||||
|         self.action_plugin = TestActionPlugin('user') | ||||
|  | ||||
|         class NameActionPlugin(ActionPlugin): | ||||
|         class NameActionPlugin(ActionMixin, IntegrationPluginBase): | ||||
|             PLUGIN_NAME = 'Aplugin' | ||||
|  | ||||
|         self.action_name = NameActionPlugin('user') | ||||
|   | ||||
| @@ -1,12 +1,13 @@ | ||||
| # -*- coding: utf-8 -*- | ||||
| """sample implementation for ActionPlugin""" | ||||
| from plugin.base.action.action import ActionPlugin | ||||
| """sample implementation for ActionMixin""" | ||||
| from plugin import IntegrationPluginBase | ||||
| from plugin.mixins import ActionMixin | ||||
|  | ||||
|  | ||||
| class SimpleActionPlugin(ActionPlugin): | ||||
| class SimpleActionPlugin(ActionMixin, IntegrationPluginBase): | ||||
|     """ | ||||
|     An EXTREMELY simple action plugin which demonstrates | ||||
|     the capability of the ActionPlugin class | ||||
|     the capability of the ActionMixin class | ||||
|     """ | ||||
|  | ||||
|     PLUGIN_NAME = "SimpleActionPlugin" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user