bangkoker.blogg.se

Snitch software
Snitch software










In order to do that, you should create a model that inherits fromĪbstractNotification: from django.db import models from snitch.models import AbstractNotification class Notification ( AbstractNotification ): """Custom notification.""" extra_field = models. You can, in the same way that .User works, swap the dispatch ( CONFIRMED_EVENT ) def confirm ( self ): self.

snitch software

dispatch ( ACTIVATED_EVENT ) def activate ( self ): self. DateTimeField ( null = True, blank = True ). DateTimeField ( null = True, blank = True ) confirmed_at = models. PositiveIntegerField ( default = IDLE ) activated_at = models. Model ): """Simple stuff model with status.""" IDLE, ACTIVE, CONFIRMED = 0, 1, 2 status = models. all ()Ĥ Use dispatch decorator to dispatch the event when a function is called: from django.db import models from django.utils import timezone import snitch from snitch.models import AbstractNotification from import ACTIVATED_EVENT, CONFIRMED_EVENT class Stuff ( models. EventHandler ): title = "Confirmed!" notification_backends = # Custom configuration for email backend template_email_kwargs = template_email_async = False def audience ( self ): return get_user_model (). register ( CONFIRMED_EVENT ) class ConfirmedHandler ( snitch. register ( ACTIVATED_EVENT ) class ActivatedHandler ( snitch. Quick startġ Install using pip: pip install django-snitchĢ Add “snitch” to your INSTALLED_APPS settings like this: INSTALLED_APPS += ( 'snitch' ,)ģ Create an events.py file in your app to register the events: import snitch from snitch.backends import PushNotificationBackend, EmailNotificationBackend ACTIVATED_EVENT = "activated" CONFIRMED_EVENT = "confirmed".

snitch software snitch software

Made with Python 3 and Django with :heart. Django app made to integrate generic events that create notifications thatĬan be sent to users using several backends.īy default, it integrates push notifications and email to send the












Snitch software