summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2009-02-23 22:46:32 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2009-02-23 22:46:32 +0000
commit1aac357d344645f31320ee832b2c2e7be41c9ba0 (patch)
tree40d79dee5ace166523097d3f9272741bc844b5fe
parent63d85a684ac713b74a8ea5fee3757139229e45a5 (diff)
Fixed #9303: comment templatetags no longer assume the built-in comment model.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9891 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/comments/templatetags/comments.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/django/contrib/comments/templatetags/comments.py b/django/contrib/comments/templatetags/comments.py
index 563a3ff901..9b12adaf6d 100644
--- a/django/contrib/comments/templatetags/comments.py
+++ b/django/contrib/comments/templatetags/comments.py
@@ -3,6 +3,7 @@ from django.template.loader import render_to_string
from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from django.contrib import comments
+from django.db.models import FieldDoesNotExist
from django.utils.encoding import smart_unicode
register = template.Library()
@@ -82,7 +83,15 @@ class BaseCommentNode(template.Node):
site__pk = settings.SITE_ID,
is_public = True,
)
- if getattr(settings, 'COMMENTS_HIDE_REMOVED', True):
+
+ # The is_public and is_removed fields are implementation details of the
+ # built-in comment model's spam filtering system, so they might not
+ # be present on a custom comment model subclass. If they exist, we
+ # should filter on them.
+ field_names = [f.name for f in self.comment_model._meta.fields]
+ if 'is_public' in field_names:
+ qs = qs.filter(is_public=True)
+ if getattr(settings, 'COMMENTS_HIDE_REMOVED', True) and 'is_removed' in field_names:
qs = qs.filter(is_removed=False)
return qs