From 52e5383887e061879617c968eb3f5cfae15bb80e Mon Sep 17 00:00:00 2001 From: J-E Castagnede Date: Tue, 2 Jul 2024 17:34:09 +0200 Subject: [PATCH 1/2] fix multipart API sent data --- docs/changelog.rst | 8 ++++++++ georiviere/portal/tests/test_views/test_contribution.py | 4 ++-- georiviere/portal/views/contribution.py | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 5b1728b5..94d661a9 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -2,6 +2,14 @@ CHANGELOG ========= +1.4.2 (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/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) From 21c08dd7c2d65683e1d780d78f568dacbb848be6 Mon Sep 17 00:00:00 2001 From: J-E Castagnede Date: Tue, 2 Jul 2024 17:35:14 +0200 Subject: [PATCH 2/2] prepare release --- docs/changelog.rst | 2 +- georiviere/VERSION | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 94d661a9..9b59cd03 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -2,7 +2,7 @@ CHANGELOG ========= -1.4.2 (2024-07-02) +1.4.3 (2024-07-02) --------------------- **Bug fix** 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