comparison forums/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 5ba2508939f7
children
comparison
equal deleted inserted replaced
1034:2f36abf65a62 1035:eeaf387803c6
5 5
6 from django.db import models 6 from django.db import models
7 from django.db.models import Q 7 from django.db.models import Q
8 from django.contrib.auth.models import User, Group 8 from django.contrib.auth.models import User, Group
9 from django.core.cache import cache 9 from django.core.cache import cache
10 from django.core.urlresolvers import reverse
10 11
11 from core.markup import site_markup 12 from core.markup import site_markup
12 from oembed.models import Oembed 13 from oembed.models import Oembed
13 14
14 15
100 ordering = ('position', ) 101 ordering = ('position', )
101 102
102 def __unicode__(self): 103 def __unicode__(self):
103 return self.name 104 return self.name
104 105
105 @models.permalink
106 def get_absolute_url(self): 106 def get_absolute_url(self):
107 return ('forums-forum_index', [self.slug]) 107 return reverse('forums-forum_index', kwargs={'slug': self.slug})
108 108
109 def topic_count_update(self): 109 def topic_count_update(self):
110 """Call to notify the forum that its topic count has been updated.""" 110 """Call to notify the forum that its topic count has been updated."""
111 self.topic_count = Topic.objects.filter(forum=self).count() 111 self.topic_count = Topic.objects.filter(forum=self).count()
112 112
192 ordering = ('-sticky', '-update_date', ) 192 ordering = ('-sticky', '-update_date', )
193 193
194 def __unicode__(self): 194 def __unicode__(self):
195 return self.name 195 return self.name
196 196
197 @models.permalink
198 def get_absolute_url(self): 197 def get_absolute_url(self):
199 return ('forums-topic_index', [self.pk]) 198 return reverse('forums-topic_index', kwargs={'id': str(self.pk)})
200 199
201 @models.permalink
202 def get_latest_post_url(self): 200 def get_latest_post_url(self):
203 return ('forums-topic_latest', [self.pk]) 201 return reverse('forums-topic_latest', kwargs={'id': str(self.pk)})
204 202
205 def post_count_update(self): 203 def post_count_update(self):
206 """ 204 """
207 Call this function to notify the topic instance that its post count 205 Call this function to notify the topic instance that its post count
208 has changed. 206 has changed.
291 ordering = ('creation_date', ) 289 ordering = ('creation_date', )
292 get_latest_by = 'creation_date' 290 get_latest_by = 'creation_date'
293 verbose_name = 'forum post' 291 verbose_name = 'forum post'
294 verbose_name_plural = 'forum posts' 292 verbose_name_plural = 'forum posts'
295 293
296 @models.permalink
297 def get_absolute_url(self): 294 def get_absolute_url(self):
298 return ('forums-goto_post', [self.pk]) 295 return reverse('forums-goto_post', args=[str(self.pk)])
299 296
300 def summary(self): 297 def summary(self):
301 limit = 65 298 limit = 65
302 if len(self.body) < limit: 299 if len(self.body) < limit:
303 return self.body 300 return self.body