def cancel(self, request, pk=None): delivery = self.get_object() self.prevent_null_email_template_set() if delivery.state != State.NEW and delivery.state != State.NOTIFIED: raise ValidationError('Only deliveries in new and notified state can be canceled.') dds_util = DDSUtil(request.user) dds_util.cancel_project_transfer(delivery.transfer_id) message_factory = DDSMessageFactory(delivery, request.user) message = message_factory.make_canceled_message() message.send() delivery.mark_canceled() return self.retrieve(request)
def cancel(self, request, pk=None): delivery = self.get_object() self.prevent_null_email_template_set() if delivery.state != State.NEW and delivery.state != State.NOTIFIED: raise ValidationError( 'Only deliveries in new and notified state can be canceled.') dds_util = DDSUtil(request.user) dds_util.cancel_project_transfer(delivery.transfer_id) message_factory = DDSMessageFactory(delivery, request.user) message = message_factory.make_canceled_message() message.send() delivery.mark_canceled() return self.retrieve(request)
def test_cancel_project_transfer(self): dds_util = DDSUtil(user=Mock()) mock_remote_store = Mock() dds_util._remote_store = mock_remote_store dds_util.cancel_project_transfer(transfer_id='123')