diff gpp/forums/models.py @ 301:ee451ad46af1

Fixing #140; limit topic notification emails to at most 1 per day, or more if the user visits the topic.
author Brian Neal <bgneal@gmail.com>
date Thu, 13 Jan 2011 03:27:42 +0000
parents c92fb89dbc7d
children 9fcd366f22dc
line wrap: on
line diff
--- a/gpp/forums/models.py	Tue Jan 11 04:04:44 2011 +0000
+++ b/gpp/forums/models.py	Thu Jan 13 03:27:42 2011 +0000
@@ -183,7 +183,7 @@
     sticky = models.BooleanField(blank=True, default=False)
     locked = models.BooleanField(blank=True, default=False)
     subscribers = models.ManyToManyField(User, related_name='subscriptions',
-            verbose_name='subscribers', blank=True)
+            verbose_name='subscribers', blank=True, through='Subscription')
     bookmarkers = models.ManyToManyField(User, related_name='favorite_topics',
             verbose_name='bookmarkers', blank=True)
 
@@ -391,3 +391,13 @@
 
     def __unicode__(self):
         return u'Post %d, %s' % (self.post.pk, self.embed.title)
+
+
+class Subscription(models.Model):
+    """
+    This model is a "through" table for the M2M relationshiop between forum
+    topics and users (subscribers).
+    """
+    topic = models.ForeignKey(Topic)
+    user = models.ForeignKey(User)
+    notify_date = models.DateTimeField(null=True)