From ba08f605c299d24536bf2c5289ccca016cc85edc Mon Sep 17 00:00:00 2001 From: thenav56 Date: Mon, 29 Jun 2020 13:12:57 +0545 Subject: [PATCH] Remove validation from servers Client will handle the custom project validations --- deployments/serializers.py | 5 +---- deployments/test_views.py | 13 +------------ 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/deployments/serializers.py b/deployments/serializers.py index 0af522d07..e292b13e5 100644 --- a/deployments/serializers.py +++ b/deployments/serializers.py @@ -15,7 +15,6 @@ OperationTypes, ProgrammeTypes, - Statuses, ) from api.serializers import ( DisasterTypeSerializer, @@ -131,9 +130,7 @@ def validate(self, data): for project in data['project_districts'][1:]: if project.country != data['project_country']: raise serializers.ValidationError(ugettext('Different country found for given districts')) - if data['status'] == Statuses.COMPLETED and data.get('reached_total') is None: - raise serializers.ValidationError(ugettext('Reached total should be provided if status is completed')) - elif ( + if ( data['operation_type'] == OperationTypes.EMERGENCY_OPERATION and data['programme_type'] == ProgrammeTypes.MULTILATERAL and data.get('event') is None diff --git a/deployments/test_views.py b/deployments/test_views.py index 28d0c5404..785a6b189 100644 --- a/deployments/test_views.py +++ b/deployments/test_views.py @@ -106,20 +106,9 @@ def test_2(self): self.assertEqual(resp.status_code, 201, resp.content) # Validation Tests - # Reached total should be provided if status is completed - body['status'] = Statuses.COMPLETED.value - body['reached_total'] = '' # The new framework does not allow None to be sent. - resp = self.client.post('/api/v2/project/', body) - self.assertEqual(resp.status_code, 400, resp.content) - - # Disaster Type should be provided if operation type is Long Term Operation - body['operation_type'] = OperationTypes.PROGRAMME.value - body['dtype'] = '' - resp = self.client.post('/api/v2/project/', body) - self.assertEqual(resp.status_code, 400, resp.content) # Event should be provided if operation type is Emergency Operation and programme type is Multilateral - body['operation_type'] = OperationTypes.PROGRAMME.value + body['operation_type'] = OperationTypes.EMERGENCY_OPERATION.value body['programme_type'] = ProgrammeTypes.MULTILATERAL.value body['event'] = '' resp = self.client.post('/api/v2/project/', body)