Beispiel #1
0
    def create(self, validated_data):
        """create.

        :param validated_data:
        :return storage_request:
        """
        # not used, use initial_data instead
        validated_data.pop('storage_product', None)
        storage_product = self.initial_data.pop('storage_product', None)
        if not storage_product or 'id' not in storage_product:
            raise ParseError('Storage product is required')

        storage_product_id = storage_product['id']
        storage_question_responses = validated_data.pop(
            'storage_question_responses', None)

        provision_details = validated_data.pop('provision_details', None)
        if provision_details:
            pSerializer = ProvisionDetailsSerializer(data=provision_details,
                                                     context=self.context)
            pSerializer.is_valid(raise_exception=True)
            validated_data['provision_details'] = pSerializer.save()

        validated_data['storage_product'] = get_storage_product_obj(
            {'pk': storage_product_id})

        storage_request = StorageRequest.objects.create(**validated_data)

        if storage_question_responses:
            for sqr in storage_question_responses:
                sqrSerializer = StorageQuestionResponseSerializer(data=sqr)
                sqrSerializer.is_valid(raise_exception=True)
                sqrSerializer.save(storage_request=storage_request)

        return storage_request
    def create(self, validated_data):
        """create.

        :param validated_data:
        :return storage_request:
        """
        # not used, use initial_data instead
        validated_data.pop('storage_product', None)
        storage_product = self.initial_data.pop('storage_product', None)
        if not storage_product or 'id' not in storage_product:
            raise ParseError('Storage product is required')

        storage_product_id = storage_product['id']
        storage_question_responses = validated_data.pop(
            'storage_question_responses', None)

        provision_details = validated_data.pop('provision_details', None)
        if provision_details:
            pSerializer = ProvisionDetailsSerializer(
                data=provision_details, context=self.context)
            pSerializer.is_valid(raise_exception=True)
            validated_data['provision_details'] = pSerializer.save()

        validated_data['storage_product'] = \
            lookupData.get_storage_product_obj({'pk': storage_product_id})

        storage_request = StorageRequest.objects.create(**validated_data)

        if storage_question_responses:
            for sqr in storage_question_responses:
                sqrSerializer = StorageQuestionResponseSerializer(data=sqr)
                sqrSerializer.is_valid(raise_exception=True)
                sqrSerializer.save(storage_request=storage_request)

        return storage_request
Beispiel #3
0
    def create(self, validated_data):
        """create.

        :param validated_data:
        :return compute_request:
        """
        compute_product = validated_data.pop('compute_product', None)
        if not compute_product or 'id' not in compute_product:
            raise ParseError('Compute product is required')

        compute_product_id = compute_product['id']
        compute_question_responses = validated_data.pop(
            'compute_question_responses', None)

        provision_details = validated_data.pop('provision_details', None)
        if provision_details:
            pSerializer = ProvisionDetailsSerializer(data=provision_details,
                                                     context=self.context)
            pSerializer.is_valid(raise_exception=True)
            validated_data['provision_details'] = pSerializer.save()

        validated_data['compute_product'] = get_compute_product_obj(
            {'pk': compute_product_id})

        compute_request = ComputeRequest.objects.create(**validated_data)
        if compute_question_responses:
            for cqr in compute_question_responses:
                cqrSerializer = ComputeQuestionResponseSerializer(data=cqr)
                cqrSerializer.is_valid(raise_exception=True)
                cqrSerializer.save(compute_request=compute_request)

        return compute_request
    def create(self, validated_data):
        """create.

        :param validated_data:
        :return compute_request:
        """
        compute_product = validated_data.pop('compute_product', None)
        if not compute_product or 'id' not in compute_product:
            raise ParseError('Compute product is required')

        compute_product_id = compute_product['id']
        compute_question_responses = validated_data.pop(
            'compute_question_responses', None)

        provision_details = validated_data.pop('provision_details', None)
        if provision_details:
            pSerializer = ProvisionDetailsSerializer(
                data=provision_details, context=self.context)
            pSerializer.is_valid(raise_exception=True)
            validated_data['provision_details'] = pSerializer.save()

        validated_data['compute_product'] = \
            lookupData.get_compute_product_obj({'pk': compute_product_id})

        compute_request = ComputeRequest.objects.create(**validated_data)
        if compute_question_responses:
            for cqr in compute_question_responses:
                cqrSerializer = ComputeQuestionResponseSerializer(data=cqr)
                cqrSerializer.is_valid(raise_exception=True)
                cqrSerializer.save(compute_request=compute_request)

        return compute_request