Changeset 399:bc710ec105af
- Timestamp:
- Mar 4, 2012 1:24:39 AM (15 months ago)
- Branch:
- default
- Location:
- djangobb_forum
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
djangobb_forum/models.py
r397 r399 315 315 316 316 317 class ProfileManager(models.Manager): 318 def get_query_set(self): 319 qs = super(ProfileManager, self).get_query_set() 320 if forum_settings.REPUTATION_SUPPORT: 321 qs = qs.extra(select={'reply_total':'Select sum(sign) from djangobb_forum_reputation group by to_user_id'}) 322 return qs 323 317 324 class Profile(models.Model): 318 325 user = AutoOneToOneField(User, related_name='forum_profile', verbose_name=_('User')) … … 338 345 post_count = models.IntegerField(_('Post count'), blank=True, default=0) 339 346 347 objects = ProfileManager() 348 340 349 class Meta: 341 350 verbose_name = _('Profile') -
djangobb_forum/views.py
r396 r399 261 261 topic.update_read(request.user) 262 262 posts = topic.posts.all().select_related() 263 #TODO rewrite264 fixed = False265 if fixed and forum_settings.REPUTATION_SUPPORT:266 replies_list = Reputation.objects.filter(to_user__pk__in=users).values('to_user_id').annotate(Sum('sign'))267 replies = {}268 for r in replies_list:269 replies[r['to_user_id']] = r['sign__sum']270 271 for post in posts:272 post.user.forum_profile.reply_total = replies.get(post.user.id, 0)273 263 274 264 initial = {} … … 541 531 posts = topic.posts.all().select_related() 542 532 543 profiles = Profile.objects.filter(user__pk__in=set(x.user.id for x in posts))544 profiles = dict((x.user_id, x) for x in profiles)545 546 for post in posts:547 post.user.forum_profile = profiles[post.user.id]548 549 533 initial = {} 550 534 if request.user.is_authenticated():
Note: See TracChangeset
for help on using the changeset viewer.
