I recently upgraded a large Django install from 1.1 to 1.3. In the Comments app, they added a caveat so only Superusers get the Delete Action.
The moderators, who have permissions to Delete, as a result don’t see those Actions. This is really inconvenient for them.
The code in question is in contrib.comments.admin starting on line 28:
def get_actions(self, request):
actions = super(CommentsAdmin, self).get_actions(request)
# Only superusers should be able to delete the comments from the DB.
if not request.user.is_superuser and 'delete_selected' in actions:
actions.pop('delete_selected')
It should instead ask if request.user has delete permissions.
How can I override this without jacking with the actual Django install?
(And if anyone knows why this was changed, I’d be interested to know.)
In the comments app, there is a “Remove selected comments” action. When you apply the this action, it ‘marks’ the comment as deleted instead of deleting from the database — it creates a deleted flag for the comment and sets
comment.is_removed = True.I recommend that you give your moderators the
comments.can_moderatepermission, and remove comments in that way. If you really want your moderators to be able to delete comments, you could do the following:CommentsAdminin admin.pyget_actionsmethodCommentsAdminModelAdmin, then register your subclass.To do this, put the following code in one of your apps.