Skip to content

Commit

Permalink
Sending the whole notification in the signal
Browse files Browse the repository at this point in the history
  • Loading branch information
jmr committed Jun 28, 2021
1 parent cc5fbc9 commit 8dfd3c7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,18 @@ from django.dispatch import receiver
from osis_notification.signals import email_notification_sent, web_notification_sent

@receiver(email_notification_sent)
def email_notification_has_been_sent(sender, notification_uuid, **kwargs):
print(f"An email notification was sent from sender {sender} with the uuid {notification_uuid}")
def email_notification_has_been_sent(sender, notification, **kwargs):
print(
f"An email notification was sent from signal sender {sender} with the"
f"uuid {notification.uuid} to {notification.person}."
)

@receiver(web_notification_sent)
def web_notification_has_been_sent(sender, notification_uuid, **kwargs):
print(f"A web notification was sent from sender {sender} with the uuid {notification_uuid}")
def web_notification_has_been_sent(sender, notification, **kwargs):
print(
f"An web notification was sent from signal sender {sender} with the"
f"uuid {notification.uuid} to {notification.person}."
)
```

## Cleaning notifications
Expand Down
2 changes: 1 addition & 1 deletion management/commands/send_email_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ def handle(self, *args, **options):
EmailNotificationHandler.process(notification)
email_notification_sent.send(
sender=self.__class__,
notification_uuid=notification.uuid,
notification=notification,
)
2 changes: 1 addition & 1 deletion management/commands/send_web_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ def handle(self, *args, **options):
WebNotificationHandler.process(notification)
web_notification_sent.send(
sender=self.__class__,
notification_uuid=notification.uuid,
notification=notification,
)
2 changes: 1 addition & 1 deletion signals/email_notification_sent.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.dispatch import Signal


email_notification_sent = Signal(providing_args=["notification_uuid"])
email_notification_sent = Signal(providing_args=["notification"])
2 changes: 1 addition & 1 deletion signals/web_notification_sent.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.dispatch import Signal


web_notification_sent = Signal(providing_args=["notification_uuid"])
web_notification_sent = Signal(providing_args=["notification"])

0 comments on commit 8dfd3c7

Please sign in to comment.