comparison gpp/forums/models.py @ 426:c8148cf11a79

Show number of posts in a topic when displaying forum topic search results. Fixing #212.
author Brian Neal <bgneal@gmail.com>
date Tue, 26 Apr 2011 01:04:38 +0000
parents b1f939b1fb01
children e9f203c5f5bb
comparison
equal deleted inserted replaced
425:76ba9478ebbd 426:c8148cf11a79
258 Post.objects.filter(topic=self).exclude(pk=self.last_post.pk).latest() 258 Post.objects.filter(topic=self).exclude(pk=self.last_post.pk).latest()
259 except Post.DoesNotExist: 259 except Post.DoesNotExist:
260 self.last_post = None 260 self.last_post = None
261 261
262 def search_title(self): 262 def search_title(self):
263 return u"%s by %s" % (self.name, self.user.username) 263 if self.post_count == 1:
264 post_text = "(1 post)"
265 else:
266 post_text = "(%d posts)" % self.post_count
267
268 return u"%s by %s; %s" % (self.name, self.user.username, post_text)
264 269
265 def search_summary(self): 270 def search_summary(self):
266 return u'' 271 return u''
267 272
268 273