From 45678f1622c99d75b1eef14d1e77f31712102de8 Mon Sep 17 00:00:00 2001 From: Shailesh Aanand Date: Mon, 15 Nov 2021 18:29:58 +0530 Subject: [PATCH] fix export error when only upper or lower limit is set --- care/facility/api/viewsets/patient.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/care/facility/api/viewsets/patient.py b/care/facility/api/viewsets/patient.py index b7500f04a4..7497c10d92 100644 --- a/care/facility/api/viewsets/patient.py +++ b/care/facility/api/viewsets/patient.py @@ -241,6 +241,10 @@ def list(self, request, *args, **kwargs): for field in self.date_range_fields: slice_obj = temp.form.cleaned_data.get(field) if slice_obj: + if not slice_obj.start or not slice_obj.stop: + raise ValidationError( + {field: f"both starting and ending date must be provided for export"} + ) days_difference = ( temp.form.cleaned_data.get(field).stop - temp.form.cleaned_data.get(field).start