Fixed #11625: added comment moderation via admin actions.

This is BACKWARDS INCOMPATIBLE if you were using the completely undocumented moderation view from 1.1. That view's been removed in favor of the admin actions.

Thanks, Thejaswi Puthraya.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@11639 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jacob Kaplan-Moss 2009-10-23 19:22:31 +00:00
parent 162fade2b7
commit 8be1bb2268
6 changed files with 126 additions and 206 deletions

View file

@ -159,31 +159,29 @@ class ApproveViewTests(CommentTestCase):
response = self.client.get("/approved/", data={"c":pk})
self.assertTemplateUsed(response, "comments/approved.html")
class AdminActionsTests(CommentTestCase):
urls = "regressiontests.comment_tests.urls_admin"
def setUp(self):
super(AdminActionsTests, self).setUp()
# Make "normaluser" a moderator
u = User.objects.get(username="normaluser")
u.is_staff = True
u.user_permissions.add(Permission.objects.get(codename='add_comment'))
u.user_permissions.add(Permission.objects.get(codename='change_comment'))
u.user_permissions.add(Permission.objects.get(codename='delete_comment'))
u.save()
class ModerationQueueTests(CommentTestCase):
def testModerationQueuePermissions(self):
"""Only moderators can view the moderation queue"""
def testActionsNonModerator(self):
comments = self.createSomeComments()
self.client.login(username="normaluser", password="normaluser")
response = self.client.get("/moderate/")
self.assertEqual(response["Location"], "http://testserver/accounts/login/?next=/moderate/")
response = self.client.get("/admin/comments/comment/")
self.assertEquals("approve_comments" in response.content, False)
makeModerator("normaluser")
response = self.client.get("/moderate/")
self.assertEqual(response.status_code, 200)
def testModerationQueueContents(self):
"""Moderation queue should display non-public, non-removed comments."""
c1, c2, c3, c4 = self.createSomeComments()
def testActionsModerator(self):
comments = self.createSomeComments()
makeModerator("normaluser")
self.client.login(username="normaluser", password="normaluser")
c1.is_public = c2.is_public = False
c1.save(); c2.save()
response = self.client.get("/moderate/")
self.assertEqual(list(response.context[0]["comments"]), [c1, c2])
c2.is_removed = True
c2.save()
response = self.client.get("/moderate/")
self.assertEqual(list(response.context[0]["comments"]), [c1])
response = self.client.get("/admin/comments/comment/")
self.assertEquals("approve_comments" in response.content, True)

View file

@ -0,0 +1,8 @@
from django.conf.urls.defaults import *
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
(r'^admin/', include(admin.site.urls)),
)