mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 20:16:44 +00:00
29 lines
795 B
Python
29 lines
795 B
Python
"""Sample plugin which responds to events."""
|
|
|
|
import logging
|
|
|
|
from django.conf import settings
|
|
|
|
from plugin import InvenTreePlugin
|
|
from plugin.mixins import EventMixin
|
|
|
|
logger = logging.getLogger('inventree')
|
|
|
|
|
|
class EventPluginSample(EventMixin, InvenTreePlugin):
|
|
"""A sample plugin which provides supports for triggered events."""
|
|
|
|
NAME = "EventPlugin"
|
|
SLUG = "sampleevent"
|
|
TITLE = "Triggered Events"
|
|
|
|
def process_event(self, event, *args, **kwargs):
|
|
"""Custom event processing."""
|
|
print(f"Processing triggered event: '{event}'")
|
|
print("args:", str(args))
|
|
print("kwargs:", str(kwargs))
|
|
|
|
# Issue warning that we can test for
|
|
if settings.PLUGIN_TESTING:
|
|
logger.debug(f'Event `{event}` triggered in sample plugin')
|