def _process_delete_items(self, items):
        for item in items:
            if 'product' not in item:
                raise OrderingError(
                    'It is required to specify product information in delete order items'
                )

            product = item['product']

            if 'id' not in product:
                raise OrderingError(
                    'It is required to provide product id in delete order items'
                )

            # Set the contract as terminated
            client = InventoryClient()
            order, contract = self._get_existing_contract(
                client, product['id'])

            # Suspend the access to the service
            on_product_suspended(order, contract)

            contract.terminated = True
            order.save()

            # Terminate product in the inventory
            client.terminate_product(product['id'])
Ejemplo n.º 2
0
    def _process_delete_items(self, items):
        for item in items:
            if 'product' not in item:
                raise OrderingError('It is required to specify product information in delete order items')

            product = item['product']

            if 'id' not in product:
                raise OrderingError('It is required to provide product id in delete order items')

            # Set the contract as terminated
            client = InventoryClient()
            order, contract = self._get_existing_contract(client, product['id'])
            contract.terminated = True

            order.save()

            # Terminate product in the inventory
            client.terminate_product(product['id'])