mirror of
https://github.com/Hopiu/django-notifications.git
synced 2026-03-16 21:30:24 +00:00
Keep the same API (but extend it) for manager methods (they turn into query set methods).
This commit is contained in:
parent
4e28b6b5d1
commit
a80c7e5fae
1 changed files with 8 additions and 2 deletions
|
|
@ -18,14 +18,20 @@ except ImportError:
|
|||
now = datetime.datetime.now
|
||||
|
||||
class NotificationQuerySet(models.query.QuerySet):
|
||||
|
||||
def unread(self):
|
||||
"Return only unread items in the current queryset"
|
||||
return self.filter(unread=True)
|
||||
|
||||
# Should we return self on these?
|
||||
def mark_all_as_read(self):
|
||||
def mark_all_as_read(self, recipient=None):
|
||||
if recipient:
|
||||
self.filter(recipient=recipient).update(unread=False)
|
||||
self.update(unread=False)
|
||||
|
||||
def mark_all_as_unread(self):
|
||||
def mark_all_as_unread(self, recipient=None):
|
||||
if recipient:
|
||||
self.filter(recipient=recipient).update(unread=True)
|
||||
self.update(unread=True)
|
||||
|
||||
class Notification(models.Model):
|
||||
|
|
|
|||
Loading…
Reference in a new issue