notifications: make user optional in .visible() filter (#13122)

This commit is contained in:
Benjamin Dauvergne 2018-03-20 11:33:24 +01:00
parent 37c1985ccc
commit 83d2de7030
1 changed files with 6 additions and 5 deletions

View File

@ -44,11 +44,12 @@ class NotificationQuerySet(QuerySet):
def ack(self):
self.update(acked=True)
def visible(self, user):
n = now()
qs = self.filter(user=user,
start_timestamp__lte=n,
end_timestamp__gt=n)
def visible(self, user=None, n=None):
qs = self
if user:
qs = qs.filter(user=user)
n = n or now()
qs = qs.filter(start_timestamp__lte=n, end_timestamp__gt=n)
return qs.order_by('-start_timestamp')
def new(self):