1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 08:21:15 +03:00

Merge pull request #1247 from wwitzel3/rbac

RBAC Fixes
This commit is contained in:
Akita Noek 2016-03-15 09:56:46 -04:00
commit d805697093
2 changed files with 5 additions and 3 deletions

View File

@ -487,9 +487,11 @@ class InventorySourceAccess(BaseAccess):
model = InventorySource model = InventorySource
def get_queryset(self): def get_queryset(self):
qs = self.model.accessible_by(self.user, {'read':True}) qs = self.model.objects
qs = qs.select_related('created_by', 'modified_by', 'group', 'inventory') qs = qs.select_related('created_by', 'modified_by', 'group', 'inventory')
return qs inventory_ids = set(self.user.get_queryset(Inventory).values_list('id', flat=True))
return qs.filter(Q(inventory_id__in=inventory_ids) |
Q(group__inventory_id__in=inventory_ids))
def can_read(self, obj): def can_read(self, obj):
if obj and obj.group: if obj and obj.group:

View File

@ -265,7 +265,7 @@ class JobTemplateTest(BaseJobTestMixin, django.test.TransactionTestCase):
# Chuck is temporarily assigned to ops east team to help them running some playbooks # Chuck is temporarily assigned to ops east team to help them running some playbooks
# even though he's in a different group and org entirely he'll now see their job templates # even though he's in a different group and org entirely he'll now see their job templates
self.team_ops_east.users.add(self.user_chuck) self.team_ops_east.deprecated_users.add(self.user_chuck)
with self.current_user(self.user_chuck): with self.current_user(self.user_chuck):
resp = self.get(url, expect=200) resp = self.get(url, expect=200)
#print [x['name'] for x in resp['results']] #print [x['name'] for x in resp['results']]