Commit 3c760ce5 authored by Jean-Baptiste Pasquier's avatar Jean-Baptiste Pasquier

fix: USER_OWNER_PERMISSIONS

parent 8fc5db79
Pipeline #4895 passed with stage
in 1 minute and 21 seconds
......@@ -7,6 +7,7 @@ from django.utils.decorators import classonlymethod
from djangoldp.permissions import LDPPermissions
User._meta.rdf_type = "foaf:user"
User._meta.owner_field = "id"
class Model(models.Model):
......
......@@ -36,7 +36,7 @@ class LDPPermissions(BasePermission):
return anonymous_perms
else:
if obj and hasattr(model._meta, 'owner_field') and getattr(obj, getattr(model._meta, 'owner_field')) == user:
if obj and hasattr(model._meta, 'owner_field') and (getattr(obj, getattr(model._meta, 'owner_field')) == user or getattr(obj, getattr(model._meta, 'owner_field')) == user.id):
return owner_perms
else:
......@@ -82,6 +82,7 @@ class LDPPermissions(BasePermission):
"""
model = view.model
perms = self.get_permissions(request.method, model)
try:
obj = view.model.resolve_id(request._request.path)
except:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment