Changing a line of code

60 views
Skip to first unread message

Andrea

unread,
Nov 18, 2014, 6:28:13 AM11/18/14
to django-d...@googlegroups.com
Dear all,

I'm using Django 1.7.1, but I needed a feature that is available only in the dev version, specifically this one:

https://github.com/django/django/commit/504c89e8008c557a1e83c45535b549f77a3503b2

I don't think this is related to the problem I have, which is the following, but I anyway need this link later.

I didn't assign any class permission to a user X for the model Y through the admin panel to delete an object, but I've overwritten the following in my `ModelAdmin` class for the model Y:

    def has_add_permission(self, request):
        return True
    
    def has_change_permission(self, request, obj=None):
        return True
   
    def has_delete_permission(self, request, obj=None):
        return True
   
    def has_module_permission(self, request):
        return True

This doesn't let the user X to delete a model Y instance, and I think the reason is here:

https://github.com/django/django/blob/master/django/contrib/admin/utils.py#L142

In my opinion, following the fix I linked at the beginning, this line should be replaced with something along the following, that is:

- if not user.has_perm(p):
+ if admin_site._registry[obj.__class__].has_delete_permission(request, obj)

(this line is wrong, I don't know where to get the `request` from, but I hope one can get the idea).

My question is: how can/should I proceed to fix this?

Thanks!
Andrea

Andrea

unread,
Nov 18, 2014, 7:10:47 AM11/18/14
to django-d...@googlegroups.com
it calls `get_deleted_objects`, which doesn't consider the method `has_delete_permission` and doesn't get the `request` instance.

Thanks for your time,
Andrea
Reply all
Reply to author
Forward
0 new messages