Skip to content

Commit

Permalink
fix multipart API sent data
Browse files Browse the repository at this point in the history
  • Loading branch information
submarcos committed Jul 2, 2024
1 parent 6ae79e7 commit 52e5383
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
8 changes: 8 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
---------------------

Expand Down
4 changes: 2 additions & 2 deletions georiviere/portal/tests/test_views/test_contribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
2 changes: 1 addition & 1 deletion georiviere/portal/views/contribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 52e5383

Please sign in to comment.