comparison gpp/messages/models.py @ 425:76ba9478ebbd

Initial beta-test commit of a revamped, jquery ui tab-based PM system. This is for #211.
author Brian Neal <bgneal@gmail.com>
date Tue, 26 Apr 2011 00:16:35 +0000
parents 272d3a8c98e8
children d0f0800eef0c
comparison
equal deleted inserted replaced
424:8df6e9edac22 425:76ba9478ebbd
12 class MessageManager(models.Manager): 12 class MessageManager(models.Manager):
13 """The manager for the Message model. Provides convenience functions.""" 13 """The manager for the Message model. Provides convenience functions."""
14 14
15 def inbox(self, user): 15 def inbox(self, user):
16 return self.filter(receiver=user, 16 return self.filter(receiver=user,
17 receiver_delete_date__isnull=True) 17 receiver_delete_date__isnull=True).select_related('sender')
18 18
19 def outbox(self, user): 19 def outbox(self, user):
20 return self.filter(sender=user, 20 return self.filter(sender=user,
21 sender_delete_date__isnull=True) 21 sender_delete_date__isnull=True).select_related('receiver')
22 22
23 def trash(self, user): 23 def trash(self, user):
24 return self.filter( 24 return self.filter(
25 Q(sender=user, sender_delete_date__isnull=False) | 25 Q(sender=user, sender_delete_date__isnull=False) |
26 Q(receiver=user, receiver_delete_date__isnull=False) 26 Q(receiver=user, receiver_delete_date__isnull=False)
27 ) 27 ).select_related()
28 28
29 def unread_count(self, user): 29 def unread_count(self, user):
30 return self.filter(receiver=user, read_date__isnull=True).count() 30 return self.filter(receiver=user, read_date__isnull=True).count()
31 31
32 32