diff --git a/notifications/__init__.py b/notifications/__init__.py index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..41f694b45c1e8fc097ccdf95e9c73b3360ad096c 100644 --- a/notifications/__init__.py +++ b/notifications/__init__.py @@ -0,0 +1 @@ +default_app_config = 'notifications.apps.Config' diff --git a/notifications/apps.py b/notifications/apps.py index 9c260e0b160c191b17c8e13b85986e5368eda49e..5a0aef11beb47c7407ecf968d3eab794db559274 100644 --- a/notifications/apps.py +++ b/notifications/apps.py @@ -3,3 +3,8 @@ from django.apps import AppConfig class NotificationsConfig(AppConfig): name = 'notifications' + + def ready(self): + super().ready() + import notifications.signals + notifications.notify = notifications.signals.notify diff --git a/notifications/signals.py b/notifications/signals.py new file mode 100644 index 0000000000000000000000000000000000000000..3de9da7d693992434fe902bc69c23086237f0910 --- /dev/null +++ b/notifications/signals.py @@ -0,0 +1,13 @@ +from django.dispatch import Signal + +notify = Signal(providing_args=[ + 'recipient', 'actor', 'verb', 'action_object', 'target', 'description', + 'timestamp', 'level' +]) + + +# Basic working method to send a notification to a user using signals: +# --- +# from notifications.signals import notify +# notify.send(user, recipient=user, verb='you reached level 10') +# ---