diff --git a/django/contrib/comments/admin.py b/django/contrib/comments/admin.py
index 28678e0..4cb9066 100644
a
|
b
|
class CommentsAdmin(admin.ModelAdmin):
|
28 | 28 | def get_actions(self, request): |
29 | 29 | actions = super(CommentsAdmin, self).get_actions(request) |
30 | 30 | # Only superusers should be able to delete the comments from the DB. |
31 | | if not request.user.is_superuser: |
| 31 | if not request.user.is_superuser and 'delete_selected' in actions: |
32 | 32 | actions.pop('delete_selected') |
33 | 33 | if not request.user.has_perm('comments.can_moderate'): |
34 | | actions.pop('approve_comments') |
35 | | actions.pop('remove_comments') |
| 34 | if 'approve_comments' in actions: |
| 35 | actions.pop('approve_comments') |
| 36 | if 'remove_comments' in actions: |
| 37 | actions.pop('remove_comments') |
36 | 38 | return actions |
37 | 39 | |
38 | 40 | def flag_comments(self, request, queryset): |
diff --git a/tests/regressiontests/comment_tests/tests/moderation_view_tests.py b/tests/regressiontests/comment_tests/tests/moderation_view_tests.py
index ef79b4d..65c9567 100644
a
|
b
|
class AdminActionsTests(CommentTestCase):
|
190 | 190 | self.client.login(username="normaluser", password="normaluser") |
191 | 191 | response = self.client.get("/admin/comments/comment/") |
192 | 192 | self.assertEquals("approve_comments" in response.content, True) |
| 193 | |
| 194 | def testActionsDisabledDelete(self): |
| 195 | "Tests a CommentAdmin where 'delete_selected' has been disabled." |
| 196 | comments = self.createSomeComments() |
| 197 | self.client.login(username="normaluser", password="normaluser") |
| 198 | response = self.client.get('/admin2/comments/comment/') |
| 199 | self.assertEqual(response.status_code, 200) |
| 200 | self.assert_( |
| 201 | '<option value="delete_selected">' not in response.content, |
| 202 | "Found an unexpected delete_selected in response" |
| 203 | ) |
diff --git a/tests/regressiontests/comment_tests/urls_admin.py b/tests/regressiontests/comment_tests/urls_admin.py
index 341285d..d7e1a4e 100644
a
|
b
|
from django.contrib.comments.models import Comment
|
8 | 8 | admin_site = admin.AdminSite() |
9 | 9 | admin_site.register(Comment, CommentsAdmin) |
10 | 10 | |
| 11 | # To demonstrate proper functionality even when ``delete_selected`` is removed. |
| 12 | admin_site2 = admin.AdminSite() |
| 13 | admin_site2.disable_action('delete_selected') |
| 14 | admin_site2.register(Comment, CommentsAdmin) |
| 15 | |
11 | 16 | urlpatterns = patterns('', |
12 | 17 | (r'^admin/', include(admin_site.urls)), |
| 18 | (r'^admin2/', include(admin_site2.urls)), |
13 | 19 | ) |