Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
102 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,21 @@ | ||
from django import template | ||
|
||
from pinax.messages.models import Thread | ||
|
||
register = template.Library() | ||
|
||
|
||
@register.filter | ||
def unread(thread, user): | ||
''' | ||
Check whether there are any unread messages for a particular thread for a user. | ||
''' | ||
return bool(thread.userthread_set.filter(user=user, unread=True)) | ||
|
||
|
||
@register.filter | ||
def unread_threads(user): | ||
''' | ||
Return the number of Threads with unread messages for this user, useful for highlighting on an account bar for example. | ||
''' | ||
return Thread.unread(user).count() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters