comparison gpp/ygroup/models.py @ 323:0c18dfb1da1c

Fixing #149; adding the ygroup application: an archive of the old Yahoo Group messages.
author Brian Neal <bgneal@gmail.com>
date Sun, 20 Feb 2011 00:31:54 +0000
parents
children 368d731af479
comparison
equal deleted inserted replaced
322:c3d3d7114749 323:0c18dfb1da1c
1 """
2 Models for the ygroup application, which is a read-only archive of messages
3 from the old Yahoo Group.
4 """
5 from django.db import models
6
7
8 class Thread(models.Model):
9 title = models.CharField(max_length=255)
10 creation_date = models.DateTimeField()
11
12 # denormalized fields to reduce database hits
13 poster = models.CharField(max_length=128)
14 post_count = models.IntegerField(blank=True, default=0)
15 page = models.IntegerField(blank=True, default=1)
16
17 class Meta:
18 ordering = ('creation_date', )
19
20 def __unicode__(self):
21 return u'Thread %d, %s' % (self.pk, self.title)
22
23 @models.permalink
24 def get_absolute_url(self):
25 return ('ygroup-thread_view', [self.id])
26
27
28 class Post(models.Model):
29 thread = models.ForeignKey(Thread, null=True, blank=True,
30 on_delete=models.SET_NULL, related_name='posts')
31 title = models.CharField(max_length=255)
32 creation_date = models.DateTimeField()
33 poster = models.CharField(max_length=128)
34 msg = models.TextField()
35
36 # precomputed URL to this post in the parent thread for efficiency
37 thread_url = models.URLField(verify_exists=False, blank=True)
38
39 class Meta:
40 ordering = ('creation_date', )
41 verbose_name = 'yahoo group post'
42 verbose_name_plural = 'yahoo group posts'
43
44 def __unicode__(self):
45 return u'Post %d, %s' % (self.pk, self.title)
46
47 @models.permalink
48 def get_absolute_url(self):
49 return ('ygroup-post_view', [], {'pk': self.id})
50
51 def search_title(self):
52 return self.title
53
54 def search_summary(self):
55 return self.msg