comparison ygroup/models.py @ 1035:eeaf387803c6

Remove usages of @models.permalink.
author Brian Neal <bgneal@gmail.com>
date Sat, 26 Dec 2015 21:33:55 -0600
parents ee87ea74d46b
children
comparison
equal deleted inserted replaced
1034:2f36abf65a62 1035:eeaf387803c6
1 """ 1 """
2 Models for the ygroup application, which is a read-only archive of messages 2 Models for the ygroup application, which is a read-only archive of messages
3 from the old Yahoo Group. 3 from the old Yahoo Group.
4 """ 4 """
5 from django.core.urlresolvers import reverse
5 from django.db import models 6 from django.db import models
6 7
7 8
8 class Thread(models.Model): 9 class Thread(models.Model):
9 title = models.CharField(max_length=255) 10 title = models.CharField(max_length=255)
18 ordering = ('creation_date', ) 19 ordering = ('creation_date', )
19 20
20 def __unicode__(self): 21 def __unicode__(self):
21 return u'Thread %d, %s' % (self.pk, self.title) 22 return u'Thread %d, %s' % (self.pk, self.title)
22 23
23 @models.permalink
24 def get_absolute_url(self): 24 def get_absolute_url(self):
25 return ('ygroup-thread_view', [self.id]) 25 return reverse('ygroup-thread_view', args=[self.pk])
26 26
27 27
28 class Post(models.Model): 28 class Post(models.Model):
29 thread = models.ForeignKey(Thread, null=True, blank=True, 29 thread = models.ForeignKey(Thread, null=True, blank=True,
30 on_delete=models.SET_NULL, related_name='posts') 30 on_delete=models.SET_NULL, related_name='posts')
42 verbose_name_plural = 'yahoo group posts' 42 verbose_name_plural = 'yahoo group posts'
43 43
44 def __unicode__(self): 44 def __unicode__(self):
45 return u'Post %d, %s' % (self.pk, self.title) 45 return u'Post %d, %s' % (self.pk, self.title)
46 46
47 @models.permalink
48 def get_absolute_url(self): 47 def get_absolute_url(self):
49 return ('ygroup-post_view', [], {'pk': self.id}) 48 return reverse('ygroup-post_view', kwargs={'pk': str(self.pk)})
50 49
51 def search_title(self): 50 def search_title(self):
52 return self.title 51 return self.title
53 52
54 def search_summary(self): 53 def search_summary(self):