Author: jacob
Date: 2009-02-23 16:46:32 -0600 (Mon, 23 Feb 2009)
New Revision: 9891

Modified:
   django/trunk/django/contrib/comments/templatetags/comments.py
Log:
Fixed #9303: comment templatetags no longer assume the built-in comment model.

Modified: django/trunk/django/contrib/comments/templatetags/comments.py
===================================================================
--- django/trunk/django/contrib/comments/templatetags/comments.py       
2009-02-23 22:16:26 UTC (rev 9890)
+++ django/trunk/django/contrib/comments/templatetags/comments.py       
2009-02-23 22:46:32 UTC (rev 9891)
@@ -3,6 +3,7 @@
 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 @@
             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


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to