diff --git a/AUTHORS b/AUTHORS
index d5faf2f244d..39ce6f86637 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -131,6 +131,7 @@ answer newbie questions, and generally made Django that much better:
Joe Heck
Joel Heenan
hipertracker@gmail.com
+ Brett Hoerner
Ian Holsman
Kieran Holland
Sung-Jin Hong
diff --git a/django/contrib/comments/models.py b/django/contrib/comments/models.py
index 5f2018881e5..a88d2b3a8e9 100644
--- a/django/contrib/comments/models.py
+++ b/django/contrib/comments/models.py
@@ -106,7 +106,10 @@ class Comment(models.Model):
return "%s: %s..." % (self.user.username, self.comment[:100])
def get_absolute_url(self):
- return self.get_content_object().get_absolute_url() + "#c" + str(self.id)
+ try:
+ return self.get_content_object().get_absolute_url() + "#c" + str(self.id)
+ except AttributeError:
+ return ""
def get_crossdomain_url(self):
return "/r/%d/%d/" % (self.content_type_id, self.object_id)
@@ -191,7 +194,10 @@ class FreeComment(models.Model):
return "%s: %s..." % (self.person_name, self.comment[:100])
def get_absolute_url(self):
- return self.get_content_object().get_absolute_url() + "#c" + str(self.id)
+ try:
+ return self.get_content_object().get_absolute_url() + "#c" + str(self.id)
+ except AttributeError:
+ return ""
def get_content_object(self):
"""
diff --git a/django/contrib/comments/templatetags/comments.py b/django/contrib/comments/templatetags/comments.py
index 756ab9c93bd..1d4628978d3 100644
--- a/django/contrib/comments/templatetags/comments.py
+++ b/django/contrib/comments/templatetags/comments.py
@@ -112,9 +112,9 @@ class CommentListNode(template.Node):
'site__id__exact': settings.SITE_ID,
}
kwargs.update(self.extra_kwargs)
- if not self.free and settings.COMMENTS_BANNED_USERS_GROUP:
- kwargs['select'] = {'is_hidden': 'user_id IN (SELECT user_id FROM auth_user_groups WHERE group_id = %s)' % settings.COMMENTS_BANNED_USERS_GROUP}
comment_list = get_list_function(**kwargs).order_by(self.ordering + 'submit_date').select_related()
+ if not self.free and settings.COMMENTS_BANNED_USERS_GROUP:
+ 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})
if not self.free:
if 'user' in context and context['user'].is_authenticated():
diff --git a/django/contrib/comments/views/comments.py b/django/contrib/comments/views/comments.py
index f166fa118f1..fbec04c8ebc 100644
--- a/django/contrib/comments/views/comments.py
+++ b/django/contrib/comments/views/comments.py
@@ -113,7 +113,7 @@ class PublicCommentManipulator(AuthenticationForm):
'This comment was posted by a user who has posted fewer than %(count)s comments:\n\n%(text)s', settings.COMMENTS_FIRST_FEW) % \
{'count': settings.COMMENTS_FIRST_FEW, 'text': c.get_as_text()}
mail_managers("Comment posted by rookie user", message)
- if settings.COMMENTS_SKETCHY_USERS_GROUP and settings.COMMENTS_SKETCHY_USERS_GROUP in [g.id for g in self.user_cache.get_group_list()]:
+ if settings.COMMENTS_SKETCHY_USERS_GROUP and settings.COMMENTS_SKETCHY_USERS_GROUP in [g.id for g in self.user_cache.groups.all()]:
message = _('This comment was posted by a sketchy user:\n\n%(text)s') % {'text': c.get_as_text()}
mail_managers("Comment posted by sketchy user (%s)" % self.user_cache.username, c.get_as_text())
return c