Skip to content

querysets

django_spire.notification.email.querysets

EmailNotificationQuerySet

Bases: HistoryQuerySet, NotificationContentObjectQuerySet

annotate_is_viewed_by_user

Source code in django_spire/notification/email/querysets.py
def annotate_is_viewed_by_user(self, user: User) -> QuerySet:
    return self.by_user(user=user).annotate(viewed=Case(
        When(views__user=user, then=Value(True)),
        default=Value(False),
        output_field=BooleanField()
    ))

by_user

Source code in django_spire/notification/email/querysets.py
def by_user(self, user: User) -> QuerySet:
    return self.filter(notification__user=user)

by_users

Source code in django_spire/notification/email/querysets.py
def by_users(self, users: list[User]):
    return self.filter(notification__user__in=users)

exclude_viewed_by_user

Source code in django_spire/notification/email/querysets.py
def exclude_viewed_by_user(self, user: User) -> QuerySet:
    return self.by_user(user=user).exclude(views__user=user)

is_sent

Source code in django_spire/notification/email/querysets.py
def is_sent(self) -> QuerySet:
    return self.filter(notification__status=NotificationStatusChoices.SENT)