added related Roles to Project, Credential, Inventory, and Group

This commit is contained in:
Wayne Witzel III
2016-05-12 09:46:39 -04:00
parent f12c6530cf
commit 0ef456e4d8
3 changed files with 76 additions and 5 deletions

View File

@@ -799,6 +799,18 @@ class OrganizationAccessList(ResourceAccessList):
resource_model = Organization
new_in_300 = True
class OrganizationRolesList(SubListAPIView):
model = Role
serializer_class = RoleSerializer
parent_model = Organization
new_in_300 = True
def get_queryset(self):
po = self.get_parent_object()
content_type = ContentType.objects.get_for_model(self.parent_model)
return Role.objects.filter(content_type=content_type, object_id=po.pk).all()
class TeamList(ListCreateAPIView):
model = Team
@@ -1064,6 +1076,18 @@ class ProjectAccessList(ResourceAccessList):
resource_model = Project
new_in_300 = True
class ProjectRolesList(SubListAPIView):
model = Role
serializer_class = RoleSerializer
parent_model = Project
new_in_300 = True
def get_queryset(self):
po = self.get_parent_object()
content_type = ContentType.objects.get_for_model(self.parent_model)
return Role.objects.filter(content_type=content_type, object_id=po.pk).all()
class UserList(ListCreateAPIView):
model = User
@@ -1359,6 +1383,18 @@ class CredentialAccessList(ResourceAccessList):
resource_model = Credential
new_in_300 = True
class CredentialRolesList(SubListAPIView):
model = Role
serializer_class = RoleSerializer
parent_model = Credential
new_in_300 = True
def get_queryset(self):
po = self.get_parent_object()
content_type = ContentType.objects.get_for_model(self.parent_model)
return Role.objects.filter(content_type=content_type, object_id=po.pk).all()
class InventoryScriptList(ListCreateAPIView):
model = CustomInventoryScript
@@ -1429,6 +1465,18 @@ class InventoryAccessList(ResourceAccessList):
resource_model = Inventory
new_in_300 = True
class InventoryRolesList(SubListAPIView):
model = Role
serializer_class = RoleSerializer
parent_model = Inventory
new_in_300 = True
def get_queryset(self):
po = self.get_parent_object()
content_type = ContentType.objects.get_for_model(self.parent_model)
return Role.objects.filter(content_type=content_type, object_id=po.pk).all()
class InventoryJobTemplateList(SubListAPIView):
model = JobTemplate
@@ -1764,6 +1812,18 @@ class GroupAccessList(ResourceAccessList):
resource_model = Group
new_in_300 = True
class GroupRolesList(SubListAPIView):
model = Role
serializer_class = RoleSerializer
parent_model = Group
new_in_300 = True
def get_queryset(self):
po = self.get_parent_object()
content_type = ContentType.objects.get_for_model(self.parent_model)
return Role.objects.filter(content_type=content_type, object_id=po.pk).all()
class InventoryGroupsList(SubListCreateAttachDetachAPIView):
@@ -2488,9 +2548,9 @@ class JobTemplateRolesList(SubListAPIView):
new_in_300 = True
def get_queryset(self):
jt = self.get_parent_object()
content_type = ContentType.objects.get_for_model(JobTemplate)
return Role.objects.filter(content_type=content_type, object_id=jt.pk).all()
po = self.get_parent_object()
content_type = ContentType.objects.get_for_model(self.parent_model)
return Role.objects.filter(content_type=content_type, object_id=po.pk).all()
class SystemJobTemplateList(ListAPIView):