Skip to content

Commit

Permalink
Only count on_site notices in the context processor (also unseen_coun…
Browse files Browse the repository at this point in the history
…t_for now calls notices_for).

git-svn-id: http://django-notification.googlecode.com/svn/trunk@159 590c3fc9-4838-0410-bb95-17a0c9b37ca9
  • Loading branch information
brosner committed Mar 13, 2009
1 parent 3f18d36 commit 0f2d6f3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion notification/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

def notification(request):
if request.user.is_authenticated():
return {'notice_unseen_count': Notice.objects.unseen_count_for(request.user),}
return {
'notice_unseen_count': Notice.objects.unseen_count_for(request.user, on_site=True),
}
else:
return {}
4 changes: 2 additions & 2 deletions notification/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ def notices_for(self, user, archived=False, unseen=None, on_site=None):
qs = qs.filter(on_site=on_site)
return qs

def unseen_count_for(self, user):
def unseen_count_for(self, user, **kwargs):
"""
returns the number of unseen notices for the given user but does not
mark them seen
"""
return self.filter(user=user, unseen=True).count()
return self.notices_for(user, unseen=True, **kwargs).count()

class Notice(models.Model):

Expand Down

0 comments on commit 0f2d6f3

Please sign in to comment.