diff --git a/notifications/models.py b/notifications/models.py index 0376b8d..a564f73 100644 --- a/notifications/models.py +++ b/notifications/models.py @@ -40,6 +40,12 @@ def assert_soft_delete(): class NotificationQuerySet(models.query.QuerySet): + def unsent(self): + return self.filter(emailed=False) + + def sent(self): + return self.filter(emailed=True) + def unread(self, include_deleted=False): """Return only unread items in the current queryset""" if is_soft_delete() and not include_deleted: @@ -117,6 +123,12 @@ class NotificationQuerySet(models.query.QuerySet): return qs.update(deleted=False) + def mark_as_unsent(self): + return self.update(emailed=False) + + def mark_as_sent(self): + return self.update(emailed=True) + class Notification(models.Model): """