Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #4189 -- Fixed crashes in a couple of corner cases in the comme…

…nts app. Not a perfect fix (see ticket), but it will do as a holdover until the new comments framework is in place.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@5848 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 9d7dc0c4bfdc7f1638acd68744a2883dd3d3d73d 1 parent 9309a8d
@malcolmt malcolmt authored
View
1  AUTHORS
@@ -131,6 +131,7 @@ answer newbie questions, and generally made Django that much better:
Joe Heck <http://www.rhonabwy.com/wp/>
Joel Heenan <joelh-django@planetjoel.com>
hipertracker@gmail.com
+ Brett Hoerner <bretthoerner@bretthoerner.com>
Ian Holsman <http://feh.holsman.net/>
Kieran Holland <http://www.kieranholland.com>
Sung-Jin Hong <serialx.net@gmail.com>
View
10 django/contrib/comments/models.py
@@ -106,7 +106,10 @@ def __repr__(self):
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 @@ def __repr__(self):
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):
"""
View
4 django/contrib/comments/templatetags/comments.py
@@ -112,9 +112,9 @@ def render(self, context):
'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():
View
2  django/contrib/comments/views/comments.py
@@ -113,7 +113,7 @@ def save(self, new_data):
'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
Please sign in to comment.
Something went wrong with that request. Please try again.