Source

django-postman / postman / context_processors.py

1
2
3
4
5
6
7
8
from postman.models import Message

def inbox(request):
    """Provide the count of unread messages for an authenticated user."""
    if request.user.is_authenticated():
        return {'postman_unread_count': Message.objects.inbox_unread_count(request.user)}
    else:
        return {}