Skip to content

Commit

Permalink
bplan/serializer: add binary=True to point JSONField as we receive a
Browse files Browse the repository at this point in the history
string containing (geo)json, not actual json
  • Loading branch information
goapunk committed Jan 7, 2025
1 parent b87bc83 commit af83df9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions docs/bplan_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ The following fields need to be provided:
- End date of the participation in
- [ISO 8601 format](https://en.wikipedia.org/wiki/ISO_8601)
(if no time zone is defined, german time zones UTC+01 and UTC+02 are used)
- *point*: geojson
- *point*: string containing valid geojson
- Location of the bplan
- Projection: WGS84 / EPSG:4326
- *(diplan only) tile_image*: string
Expand Down Expand Up @@ -203,7 +203,7 @@ curl \
"office_worker_email": "test@example.com",
"start_date": "2019-01-01T00:00",
"end_date": "2022-01-01T00:00",
"point": {"type": "Feature","geometry": {"type": "Point", "coordinates":[13.411924777644563,52.499598134440944]}}
"point": "{\"type\": \"Feature\",\"geometry\": {\"type\": \"Point\", \"coordinates\":[13.411924777644563,52.499598134440944]}}"
}
'
```
Expand All @@ -224,7 +224,7 @@ curl -X POST http://127.0.0.1:8003/api/organisations/1/bplan/ \
"office_worker_email": "test@example.com",
"start_date": "2019-01-01T00:00",
"end_date": "2022-01-01T00:00",
"point": {"type": "Feature","geometry": {"type": "Point", "coordinates":[13.411924777644563,52.499598134440944]}}
"point": "{\"type\": \"Feature\",\"geometry\": {\"type\": \"Point\", \"coordinates\":[13.411924777644563,52.499598134440944]}}"
}
'
```
Expand Down
2 changes: 1 addition & 1 deletion meinberlin/apps/bplan/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class BplanSerializer(serializers.ModelSerializer):
)
# overwrite the point model field so it's expecting json, the original field is validated as a string and therefore
# doesn't pass validation when not receiving a string
point = serializers.JSONField(required=False, write_only=True)
point = serializers.JSONField(required=False, write_only=True, binary=True)

class Meta:
model = Bplan
Expand Down

0 comments on commit af83df9

Please sign in to comment.