organizations.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:ws-backend-community 作者: lavalamp- 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号