Fixed up access_list functionality

This commit is contained in:
Akita Noek
2016-04-15 16:47:12 -04:00
parent 5e7b6ed084
commit 302774e85d
2 changed files with 8 additions and 3 deletions

View File

@@ -13,6 +13,7 @@ from django.shortcuts import get_object_or_404
from django.template.loader import render_to_string
from django.utils.encoding import smart_text
from django.utils.safestring import mark_safe
from django.contrib.contenttypes.models import ContentType
# Django REST Framework
from rest_framework.authentication import get_authorization_header
@@ -475,7 +476,9 @@ class ResourceAccessList(ListAPIView):
resource_model = getattr(self, 'resource_model')
obj = resource_model.objects.get(pk=self.object_id)
roles = set([p.role for p in obj.role_permissions.all()])
content_type = ContentType.objects.get_for_model(obj)
roles = set(Role.objects.filter(content_type=content_type, object_id=obj.id))
ancestors = set()
for r in roles:
ancestors.update(set(r.ancestors.all()))