summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2011-04-29 15:11:17 +0000
committerJannis Leidel <jannis@leidel.info>2011-04-29 15:11:17 +0000
commit0fa8bd3d92efd96d5760e39c7dd24ac70329d338 (patch)
treea1b71de2e9edbcfc357e08561e46c4e48deeb9d4
parent22892c31f6b3dbc292f7a24051986a105d22bab6 (diff)
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
-rw-r--r--django/conf/global_settings.py4
-rw-r--r--django/contrib/comments/feeds.py4
-rw-r--r--docs/releases/1.4.txt42
3 files changed, 42 insertions, 8 deletions
diff --git a/django/conf/global_settings.py b/django/conf/global_settings.py
index b57a64640f..1ab9b498a9 100644
--- a/django/conf/global_settings.py
+++ b/django/conf/global_settings.py
@@ -453,10 +453,6 @@ COMMENTS_ALLOW_PROFANITIES = False
# 'hasNoProfanities' validator. All of these should be in lowercase.
PROFANITIES_LIST = ()
-# The group ID that designates which users are banned.
-# Set to None if you're not using it.
-COMMENTS_BANNED_USERS_GROUP = None
-
##################
# AUTHENTICATION #
##################
diff --git a/django/contrib/comments/feeds.py b/django/contrib/comments/feeds.py
index e74ca2dfde..db4b2f818e 100644
--- a/django/contrib/comments/feeds.py
+++ b/django/contrib/comments/feeds.py
@@ -28,10 +28,6 @@ class LatestCommentFeed(Feed):
is_public = True,
is_removed = False,
)
- if getattr(settings, 'COMMENTS_BANNED_USERS_GROUP', None):
- where = ['user_id NOT IN (SELECT user_id FROM auth_user_groups WHERE group_id = %s)']
- params = [settings.COMMENTS_BANNED_USERS_GROUP]
- qs = qs.extra(where=where, params=params)
return qs.order_by('-submit_date')[:40]
def item_pubdate(self, item):
diff --git a/docs/releases/1.4.txt b/docs/releases/1.4.txt
index e86e07031a..617c3ad138 100644
--- a/docs/releases/1.4.txt
+++ b/docs/releases/1.4.txt
@@ -117,3 +117,45 @@ subsequently raise a 404. Requesting ``/notaflatpageoravalidurl`` now will
immediately raise a 404. Additionally redirects returned by flatpages are now
permanent (301 status code) to match the behaviour of the
:class:`~django.middleware.common.CommonMiddleware`.
+
+`COMMENTS_BANNED_USERS_GROUP` setting
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Django's :doc:`comments app </ref/contrib/comments/index>` has historically
+supported excluding the comments of a special user group but never documented
+the feature properly and didn't enforce the exclusion in other parts of the
+app, e.g. the template tags. To fix this problem the code was removed from
+the feed class.
+
+If you rely on the feature and want to restore the old behaviour, simply use
+a custom comment model manager to exclude the user group, e.g.::
+
+ from django.conf import settings
+ from django.contrib.comments.managers import CommentManager
+
+ class BanningCommentManager(CommentManager):
+
+ def get_query_set(self):
+ qs = super(BanningCommentManager, self).get_query_set()
+ if getattr(settings, 'COMMENTS_BANNED_USERS_GROUP', None):
+ where = ['user_id NOT IN (SELECT user_id FROM auth_user_groups WHERE group_id = %s)']
+ params = [settings.COMMENTS_BANNED_USERS_GROUP]
+ qs = qs.extra(where=where, params=params)
+ return qs
+
+Save this model manager in your custom comment app (e.g. in
+``my_comments_app/managers.py``) and add it your
+:ref:`custom comment app model <custom-comment-app-api>`::
+
+ from django.db import models
+ from django.contrib.comments.models import Comment
+
+ from my_comments_app.managers import BanningCommentManager
+
+ class CommentWithTitle(Comment):
+ title = models.CharField(max_length=300)
+
+ objects = BanningCommentManager()
+
+For more details see the docs about
+:doc:`customizing the comments framework </ref/contrib/comments/custom>`.