comparison 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
comparison
equal deleted inserted replaced
300:58e9b8b2965f 301:ee451ad46af1
181 user = models.ForeignKey(User) 181 user = models.ForeignKey(User)
182 view_count = models.IntegerField(blank=True, default=0) 182 view_count = models.IntegerField(blank=True, default=0)
183 sticky = models.BooleanField(blank=True, default=False) 183 sticky = models.BooleanField(blank=True, default=False)
184 locked = models.BooleanField(blank=True, default=False) 184 locked = models.BooleanField(blank=True, default=False)
185 subscribers = models.ManyToManyField(User, related_name='subscriptions', 185 subscribers = models.ManyToManyField(User, related_name='subscriptions',
186 verbose_name='subscribers', blank=True) 186 verbose_name='subscribers', blank=True, through='Subscription')
187 bookmarkers = models.ManyToManyField(User, related_name='favorite_topics', 187 bookmarkers = models.ManyToManyField(User, related_name='favorite_topics',
188 verbose_name='bookmarkers', blank=True) 188 verbose_name='bookmarkers', blank=True)
189 189
190 # denormalized fields to reduce database hits 190 # denormalized fields to reduce database hits
191 post_count = models.IntegerField(blank=True, default=0) 191 post_count = models.IntegerField(blank=True, default=0)
389 class Meta: 389 class Meta:
390 ordering = ('order', ) 390 ordering = ('order', )
391 391
392 def __unicode__(self): 392 def __unicode__(self):
393 return u'Post %d, %s' % (self.post.pk, self.embed.title) 393 return u'Post %d, %s' % (self.post.pk, self.embed.title)
394
395
396 class Subscription(models.Model):
397 """
398 This model is a "through" table for the M2M relationshiop between forum
399 topics and users (subscribers).
400 """
401 topic = models.ForeignKey(Topic)
402 user = models.ForeignKey(User)
403 notify_date = models.DateTimeField(null=True)