diff --git a/docs/changelog.rst b/docs/changelog.rst index 5b1728b5..9b59cd03 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -2,6 +2,14 @@ CHANGELOG ========= +1.4.3 (2024-07-02) +--------------------- + +**Bug fix** + +- Fix to give multipart data as JSON data in custom contribution API + + 1.4.2 (2024-07-02) --------------------- diff --git a/georiviere/VERSION b/georiviere/VERSION index c9929e36..3c80e4f0 100644 --- a/georiviere/VERSION +++ b/georiviere/VERSION @@ -1 +1 @@ -1.4.2 \ No newline at end of file +1.4.3 \ No newline at end of file diff --git a/georiviere/portal/tests/test_views/test_contribution.py b/georiviere/portal/tests/test_views/test_contribution.py index bf61a220..8cf22ff9 100644 --- a/georiviere/portal/tests/test_views/test_contribution.py +++ b/georiviere/portal/tests/test_views/test_contribution.py @@ -384,9 +384,9 @@ def test_no_values_on_not_required(self): """Null and empty values should be accepted on non required fields""" data = { "station": self.station.pk, - self.string_field.key: None, + self.string_field.key: "", self.string_field_blank.key: "", - "field_boolean": None, + "field_boolean": "", "field_float": 1.1, "contributed_at": "2020-01-01T00:00" } diff --git a/georiviere/portal/views/contribution.py b/georiviere/portal/views/contribution.py index 249795fa..8272c7bc 100644 --- a/georiviere/portal/views/contribution.py +++ b/georiviere/portal/views/contribution.py @@ -189,7 +189,7 @@ def create_contribution(self, request, *args, **kwargs): custom_type = self.get_object() context["custom_type"] = custom_type # as data come from form, we need to clean None values in creation mode - data = {k: v for k, v in request.data.items() if v is not None} + data = {k: v for k, v in request.data.items() if v} serializer = self.get_serializer(data=data, context=context) if not serializer.is_valid(): return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)