def retrieve_organization_scan_config(request, pk=None):
"""
Retrieve the ScanConfig associated with the referenced organization.
:param request: The request received by this API handler.
:param pk: The primary key of the organization to retrieve the ScanConfig for.
:return: A response containing the ScanConfig associated with the given Organization.
"""
if request.user.is_superuser:
query = rest.models.Organization.objects
else:
query = rest.models.Organization.objects.filter(
auth_groups__users=request.user,
auth_groups__name="org_read",
)
try:
organization = query.get(pk=pk)
except rest.models.Organization.DoesNotExist:
raise NotFound()
if not organization.scan_config:
raise NotFound()
else:
return_data = rest.serializers.ScanConfigSerializer(organization.scan_config)
return Response(return_data.data)
评论列表
文章目录