mirror of https://github.com/django/django.git
Fixed #4189 -- Fixed crashes in a couple of corner cases in the comments 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
This commit is contained in:
parent
9309a8d6c3
commit
9d7dc0c4bf
1
AUTHORS
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>
|
||||
|
|
|
@ -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):
|
||||
"""
|
||||
|
|
|
@ -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():
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue