1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-30 05:25:29 +03:00

Super users can list what projects an organization is assigned to.

This commit is contained in:
Michael DeHaan 2013-03-31 22:04:52 -04:00
parent 3b97dced59
commit 987abb1663
2 changed files with 17 additions and 0 deletions

View File

@ -176,6 +176,21 @@ class ProjectsDetail(BaseDetail):
serializer_class = ProjectSerializer
permission_classes = (CustomRbac,)
class ProjectsOrganizationsList(BaseSubList):
model = Organization
serializer_class = OrganizationSerializer
permission_classes = (CustomRbac,)
parent_model = Project
relationship = 'organizations'
postable = False
def _get_queryset(self):
project = Project.objects.get(pk=self.kwargs['pk'])
if not self.request.user.is_superuser:
raise PermissionDenied()
return Organization.objects.filter(projects__in = [ project ])
class TagsDetail(BaseDetail):
model = Tag

View File

@ -39,6 +39,7 @@ views_UsersAdminOrganizationsList = views.UsersAdminOrganizationsList.as_view()
# projects service
views_ProjectsList = views.ProjectsList.as_view()
views_ProjectsDetail = views.ProjectsDetail.as_view()
views_ProjectsOrganizationsList = views.ProjectsOrganizationsList.as_view()
# audit trail service
@ -96,6 +97,7 @@ urlpatterns = patterns('',
# projects service
url(r'^api/v1/projects/$', views_ProjectsList),
url(r'^api/v1/projects/(?P<pk>[0-9]+)/$', views_ProjectsDetail),
url(r'^api/v1/projects/(?P<pk>[0-9]+)/organizations/$', views_ProjectsOrganizationsList),
# audit trail service
# api/v1/audit_trails/