In a Django/Wagtail project, I use a CustomImage model inheriting from Wagtail's AbstractImage/Image model. When I want to set Image permissions for a new group of users, it doesn't work though, because the function
set_permission_policy() from the source file permissions.py takes the original (Wagtail) Image model as an argument
auth_model while it should take my CustomImage model (as the users have permissions regarding the CustomImage model):
def set_permission_policy(): """Sets the permission policy for the current image model.""" global permission_policy permission_policy = CollectionOwnershipPermissionPolicy( get_image_model(), auth_model=Image, owner_field_name="uploaded_by_user" )
When I experimentally changed the value of auth_model in the source code to my CustomImage model, everything started working, but I need a solution which will be based on modifying my code and not the source Wagtail code.
Everytime Wagtail checks permission policy (e.g. in views), it imports directly the wagtail.images.permissions.
How to change it in my code so that the permission policy can be set for my CustomImage model and not for the original Wagtail's Image model?