Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can_undelete permission is not model specific #105

Open
wmacbmcd opened this issue Mar 14, 2024 · 1 comment
Open

can_undelete permission is not model specific #105

wmacbmcd opened this issue Mar 14, 2024 · 1 comment

Comments

@wmacbmcd
Copy link

If i'm creating two models, and inheriting the meta class on both, a can_undelete permission will be created for each of them.

class ModelA(SoftDeleteObject, models.Model):
    class Meta(SoftDeleteObject.Meta):
        verbose_name = "Model A"

    some_field = models.CharField() 
class ModelB(SoftDeleteObject, models.Model):
    class Meta(SoftDeleteObject.Meta):
        verbose_name = "Model A"

    some_field = models.CharField()

If i then assign the can_undelete permission for ModelA to user1, and assign can_delete for ModelB to user2, both users will be able to undelete ModelA and ModelB objects, because the permission's codename is not unique.

@stvnw
Copy link

stvnw commented Mar 14, 2024

Furthermore so long as a user has the change_softdeletedrecord and view_changeset permissions, then the user can undelete objects in any model to which the user has only view_<model> permission (at least through the admin). Even though the user may not have change_<model> permission, they are able to effectively change the deleted_at field on said model.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants