Ticket #4189: djt-4189-combined.diff

File djt-4189-combined.diff, 3.2 KB (added by Jeremy Dunck <jdunck@…>, 18 years ago)

Supercedes previous 2 patches.

  • django/contrib/comments/templatetags/comments.py

     
    111111            'site__id__exact': settings.SITE_ID,
    112112        }
    113113        kwargs.update(self.extra_kwargs)
     114        comment_list = get_list_function(**kwargs).order_by(self.ordering + 'submit_date').select_related()
    114115        if not self.free and settings.COMMENTS_BANNED_USERS_GROUP:
    115             kwargs['select'] = {'is_hidden': 'user_id IN (SELECT user_id FROM auth_user_groups WHERE group_id = %s)' % settings.COMMENTS_BANNED_USERS_GROUP}
    116         comment_list = get_list_function(**kwargs).order_by(self.ordering + 'submit_date').select_related()
     116            comment_list = comment_list.extra(select={'is_hidden': 'user_id IN (SELECT user_id FROM auth_user_groups WHERE group_id = %s)' % settings.COMMENTS_BANNED_USERS_GROUP})
    117117
    118118        if not self.free:
    119119            if 'user' in context and context['user'].is_authenticated():
  • django/contrib/comments/models.py

     
    106106        return "%s: %s..." % (self.user.username, self.comment[:100])
    107107
    108108    def get_absolute_url(self):
    109         return self.get_content_object().get_absolute_url() + "#c" + str(self.id)
     109        try:
     110            return self.get_content_object().get_absolute_url() + "#c" + str(self.id)
     111        except AttributeError:
     112            return ""
    110113
    111114    def get_crossdomain_url(self):
    112115        return "/r/%d/%d/" % (self.content_type_id, self.object_id)
     
    191194        return "%s: %s..." % (self.person_name, self.comment[:100])
    192195
    193196    def get_absolute_url(self):
    194         return self.get_content_object().get_absolute_url() + "#c" + str(self.id)
     197        try:
     198            return self.get_content_object().get_absolute_url() + "#c" + str(self.id)
     199        except AttributeError:
     200            return ""
    195201
    196202    def get_content_object(self):
    197203        """
  • django/contrib/comments/views/comments.py

     
    112112                'This comment was posted by a user who has posted fewer than %(count)s comments:\n\n%(text)s', settings.COMMENTS_FIRST_FEW) % \
    113113                {'count': settings.COMMENTS_FIRST_FEW, 'text': c.get_as_text()}
    114114            mail_managers("Comment posted by rookie user", message)
    115         if settings.COMMENTS_SKETCHY_USERS_GROUP and settings.COMMENTS_SKETCHY_USERS_GROUP in [g.id for g in self.user_cache.get_group_list()]:
     115        if settings.COMMENTS_SKETCHY_USERS_GROUP and settings.COMMENTS_SKETCHY_USERS_GROUP in [g.id for g in self.user_cache.groups.all()]:
    116116            message = _('This comment was posted by a sketchy user:\n\n%(text)s') % {'text': c.get_as_text()}
    117117            mail_managers("Comment posted by sketchy user (%s)" % self.user_cache.username, c.get_as_text())
    118118        return c
Back to Top