Skip to content

App Notification

Source

django_spire.notification.app.models.AppNotification

Bases: ViewedModelMixin, HistoryModelMixin

notification = models.OneToOneField(Notification, editable=False, on_delete=models.CASCADE, related_name='app', related_query_name='app') class-attribute instance-attribute

template = models.TextField(default='django_spire/notification/app/item/notification_item.html') class-attribute instance-attribute

context_data = models.JSONField(default=dict) class-attribute instance-attribute

objects = AppNotificationQuerySet.as_manager() class-attribute instance-attribute

verbose_time_since_delivered property

Meta

db_table = 'django_spire_notification_app' class-attribute instance-attribute

verbose_name = 'App Notification' class-attribute instance-attribute

verbose_name_plural = 'App Notifications' class-attribute instance-attribute

__str__

Source code in django_spire/notification/app/models.py
def __str__(self):
    return f'{self.notification.title}'

as_dict

Source code in django_spire/notification/app/models.py
def as_dict(self) -> dict:
    return {
        'id': self.id,
        'title': self.notification.title,
        'body': self.notification.body,
        'context_data': self.context_data,
        'priority': self.notification.priority,
        'url': self.notification.url,
        'time_since_delivered': self.verbose_time_since_delivered,
    }

as_json

Source code in django_spire/notification/app/models.py
def as_json(self) -> str:
    return json.dumps(self.as_dict())