2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-01 11:10:54 +00:00

refactor events

This commit is contained in:
Matthias
2022-05-11 13:28:59 +02:00
parent 5a139ec74b
commit 970503f424
10 changed files with 39 additions and 31 deletions

View File

@ -3,16 +3,20 @@ Utility file to enable simper imports
"""
from .registry import registry
from .base.event.events import trigger_event
from .plugin import InvenTreePluginBase, IntegrationPluginBase
from .base.action.action import ActionPlugin
from .helpers import MixinNotImplementedError, MixinImplementationError
__all__ = [
'registry',
'trigger_event',
'ActionPlugin',
'IntegrationPluginBase',
'InvenTreePluginBase',
'registry',
'MixinNotImplementedError',
'MixinImplementationError',
]

View File

@ -0,0 +1,29 @@
"""Plugin mixin class for events"""
from plugin.helpers import MixinNotImplementedError
class EventMixin:
"""
Mixin that provides support for responding to triggered events.
Implementing classes must provide a "process_event" function:
"""
def process_event(self, event, *args, **kwargs):
"""
Function to handle events
Must be overridden by plugin
"""
# Default implementation does not do anything
raise MixinNotImplementedError
class MixinMeta:
"""
Meta options for this mixin
"""
MIXIN_NAME = 'Events'
def __init__(self):
super().__init__()
self.add_mixin('events', True, __class__)

View File

@ -238,32 +238,6 @@ class ScheduleMixin:
logger.warning("unregister_tasks failed, database not ready")
class EventMixin:
"""
Mixin that provides support for responding to triggered events.
Implementing classes must provide a "process_event" function:
"""
def process_event(self, event, *args, **kwargs):
"""
Function to handle events
Must be overridden by plugin
"""
# Default implementation does not do anything
raise MixinNotImplementedError
class MixinMeta:
"""
Meta options for this mixin
"""
MIXIN_NAME = 'Events'
def __init__(self):
super().__init__()
self.add_mixin('events', True, __class__)
class UrlsMixin:
"""
Mixin that enables custom URLs for the plugin

View File

@ -2,12 +2,13 @@
Utility class to enable simpler imports
"""
from ..base.integration.mixins import APICallMixin, AppMixin, LabelPrintingMixin, SettingsMixin, EventMixin, ScheduleMixin, UrlsMixin, NavigationMixin, PanelMixin
from ..base.integration.mixins import APICallMixin, AppMixin, LabelPrintingMixin, SettingsMixin, ScheduleMixin, UrlsMixin, NavigationMixin, PanelMixin
from common.notifications import SingleNotificationMethod, BulkNotificationMethod
from ..base.action.mixins import ActionMixin
from ..base.barcodes.mixins import BarcodeMixin
from ..base.events.mixins import EventMixin
__all__ = [
'APICallMixin',