Beispiel #1
0
    def create(self, request):
        """
        Create Organization

        :param request: create parameter
        :return: organization ID
        :rtype: uuid
        """
        serializer = OrganizationCreateBody(data=request.data)
        if serializer.is_valid(raise_exception=True):
            name = serializer.validated_data.get("name")
            try:
                Organization.objects.get(name=name)
            except ObjectDoesNotExist:
                pass
            else:
                raise ResourceExists

            CryptoConfig(name).create()
            CryptoGen(name).generate()

            msp, tls = self._conversion_msp_tls(name)

            organization = Organization(name=name, msp=msp, tls=tls)
            organization.save()

            response = OrganizationIDSerializer(data=organization.__dict__)
            if response.is_valid(raise_exception=True):
                return Response(response.validated_data,
                                status=status.HTTP_201_CREATED)
Beispiel #2
0
    def create(self, request):

        serializer = OrganizationCreateBody(data=request.data)
        if serializer.is_valid(raise_exception=True):
            org_name = serializer.validated_data.get("name")
            org_type = serializer.validated_data.get("type")
            try:
                Organization.objects.get(name=org_name)
            except ObjectDoesNotExist:
                pass

            CryptoConfig(org_name).create()
            CryptoGen(org_name).generate()

            organization = Organization(name=org_name)
            organization.save()

            response = OrganizationIDSerializer(data=organization.__dict__)
            if response.is_valid(raise_exception=True):
                return Response(response.validated_data,
                                status=status.HTTP_201_CREATED)
Beispiel #3
0
    def create(self, request):
        """
        Create Organization

        Create Organization
        """
        serializer = OrganizationCreateBody(data=request.data)
        if serializer.is_valid(raise_exception=True):
            name = serializer.validated_data.get("name")
            try:
                Organization.objects.get(name=name)
            except ObjectDoesNotExist:
                pass
            else:
                raise ResourceExists
            organization = Organization(name=name)
            organization.save()

            response = OrganizationIDSerializer(data=organization.__dict__)
            if response.is_valid(raise_exception=True):
                return Response(response.validated_data,
                                status=status.HTTP_201_CREATED)
Beispiel #4
0
    def create(self, request):
        """
        Create Organization

        Create Organization
        """
        serializer = OrganizationCreateBody(data=request.data)
        if serializer.is_valid(raise_exception=True):
            name = serializer.validated_data.get("name")
            try:
                Organization.objects.get(name=name)
            except ObjectDoesNotExist:
                pass
            else:
                raise ResourceExists
            organization = Organization(name=name)
            organization.save()

            response = OrganizationIDSerializer(data=organization.__dict__)
            if response.is_valid(raise_exception=True):
                return Response(
                    response.validated_data, status=status.HTTP_201_CREATED
                )