Commit e4e65ab8 authored by Jean-Baptiste Pasquier's avatar Jean-Baptiste Pasquier

fix: instance of on requests

parent 29aaeb66
Pipeline #7018 passed with stage
in 27 seconds
......@@ -6,15 +6,16 @@ class ProjectPermissions(LDPPermissions):
def user_permissions(self, user, obj_or_model, obj=None):
if not user.is_anonymous:
if isinstance(obj_or_model, ModelBase):
return ['view', 'add']
else:
if not isinstance(obj_or_model, ModelBase):
obj = obj_or_model
if obj:
if obj.members.filter(user=user).exists():
if obj.members.filter(user=user).get().is_admin:
return ['view', 'add', 'change', 'delete']
else:
return ['view']
else:
return ['view', 'add']
return []
......@@ -23,11 +24,12 @@ class ProjectMemberPermissions(LDPPermissions):
def user_permissions(self, user, obj_or_model, obj=None):
if not user.is_anonymous:
if isinstance(obj_or_model, ModelBase):
return ['view', 'add']
else:
if not isinstance(obj_or_model, ModelBase):
obj = obj_or_model
if obj.user == user:
if obj:
if not hasattr(obj, 'user'):
return ['view', 'add']
elif obj.user == user:
if obj.is_admin and obj.project.members.filter(is_admin=True).count() == 1:
return ['view']
else:
......@@ -41,5 +43,7 @@ class ProjectMemberPermissions(LDPPermissions):
return ['view', 'add', 'delete']
else:
return ['view']
else:
return ['view', 'add']
return []
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