2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-16 12:05:53 +00:00
Files
InvenTree/InvenTree/plugin/samples/event/event_sample.py
2022-05-28 02:43:33 +02:00

28 lines
737 B
Python

"""Sample plugin which responds to events"""
import warnings
from django.conf import settings
from plugin import InvenTreePlugin
from plugin.mixins import EventMixin
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:
warnings.warn(f'Event `{event}` triggered')