Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #15920 -- Removed COMMENTS_BANNED_USERS_GROUP setting in favor …

…of the established comments app customization. Thanks, Daniel Lindsley.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16124 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 0fa8bd3d92efd96d5760e39c7dd24ac70329d338 1 parent 22892c3
Jannis Leidel authored April 29, 2011
4  django/conf/global_settings.py
@@ -453,10 +453,6 @@
453 453
 # 'hasNoProfanities' validator. All of these should be in lowercase.
454 454
 PROFANITIES_LIST = ()
455 455
 
456  
-# The group ID that designates which users are banned.
457  
-# Set to None if you're not using it.
458  
-COMMENTS_BANNED_USERS_GROUP = None
459  
-
460 456
 ##################
461 457
 # AUTHENTICATION #
462 458
 ##################
4  django/contrib/comments/feeds.py
@@ -28,10 +28,6 @@ def items(self):
28 28
             is_public = True,
29 29
             is_removed = False,
30 30
         )
31  
-        if getattr(settings, 'COMMENTS_BANNED_USERS_GROUP', None):
32  
-            where = ['user_id NOT IN (SELECT user_id FROM auth_user_groups WHERE group_id = %s)']
33  
-            params = [settings.COMMENTS_BANNED_USERS_GROUP]
34  
-            qs = qs.extra(where=where, params=params)
35 31
         return qs.order_by('-submit_date')[:40]
36 32
 
37 33
     def item_pubdate(self, item):
42  docs/releases/1.4.txt
@@ -117,3 +117,45 @@ subsequently raise a 404. Requesting ``/notaflatpageoravalidurl`` now will
117 117
 immediately raise a 404. Additionally redirects returned by flatpages are now
118 118
 permanent (301 status code) to match the behaviour of the
119 119
 :class:`~django.middleware.common.CommonMiddleware`.
  120
+
  121
+`COMMENTS_BANNED_USERS_GROUP` setting
  122
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  123
+
  124
+Django's :doc:`comments app </ref/contrib/comments/index>` has historically
  125
+supported excluding the comments of a special user group but never documented
  126
+the feature properly and didn't enforce the exclusion in other parts of the
  127
+app, e.g. the template tags. To fix this problem the code was removed from
  128
+the feed class.
  129
+
  130
+If you rely on the feature and want to restore the old behaviour, simply use
  131
+a custom comment model manager to exclude the user group, e.g.::
  132
+
  133
+    from django.conf import settings
  134
+    from django.contrib.comments.managers import CommentManager
  135
+
  136
+    class BanningCommentManager(CommentManager):
  137
+
  138
+        def get_query_set(self):
  139
+            qs = super(BanningCommentManager, self).get_query_set()
  140
+            if getattr(settings, 'COMMENTS_BANNED_USERS_GROUP', None):
  141
+                where = ['user_id NOT IN (SELECT user_id FROM auth_user_groups WHERE group_id = %s)']
  142
+                params = [settings.COMMENTS_BANNED_USERS_GROUP]
  143
+                qs = qs.extra(where=where, params=params)
  144
+            return qs
  145
+
  146
+Save this model manager in your custom comment app (e.g. in
  147
+``my_comments_app/managers.py``) and add it your
  148
+:ref:`custom comment app model <custom-comment-app-api>`::
  149
+
  150
+    from django.db import models
  151
+    from django.contrib.comments.models import Comment
  152
+
  153
+    from my_comments_app.managers import BanningCommentManager
  154
+
  155
+    class CommentWithTitle(Comment):
  156
+        title = models.CharField(max_length=300)
  157
+
  158
+        objects = BanningCommentManager()
  159
+
  160
+For more details see the docs about
  161
+:doc:`customizing the comments framework </ref/contrib/comments/custom>`.

0 notes on commit 0fa8bd3

Please sign in to comment.
Something went wrong with that request. Please try again.