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:
parent
3b97dced59
commit
987abb1663
@ -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
|
||||
|
@ -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/
|
||||
|
Loading…
Reference in New Issue
Block a user