-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bplan: make some further adjustments to the bplan api to fix some iss…
…ue with diplan
- Loading branch information
Showing
5 changed files
with
108 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,9 +77,12 @@ The following fields need to be provided: | |
- *name*: string | ||
- Name of the BPLAN (e.g. used as the title of the project tile) | ||
- Maximum length of 120 chars | ||
- *identifier*: string | ||
- *(imperia only) identifier*: string | ||
- Identifier that clearly identifies the BPLAN, needs to be the same as in the FIS Broker (e.g. `VIII - 329`) | ||
- Maximum length of 120 chars | ||
- (diplan only) bplan_id*: string | ||
- Id that clearly identifies the BPLAN, needs to be the same as in the FIS Broker (e.g. `VIII - 329`) | ||
- Maximum length of 120 chars | ||
- *description*: string | ||
- Description of the BPLAN shown in the project tile | ||
- Maximum length of 250 chars | ||
|
@@ -98,9 +101,10 @@ 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 | ||
- string containing coordinates separated by a comma, e.g. "1492195.544958444,6895923.461738203" | ||
- Location of the bplan | ||
- Projection: WGS84 / EPSG:4326 or EPSG:3857 | ||
- Projection: WGS84 / EPSG:3857 | ||
- *image_url*: string | ||
- URL of the image that is used in the project tile | ||
- Minimal resolution 500x300 px (width x height) | ||
|
@@ -114,22 +118,13 @@ The following fields need to be provided: | |
```json | ||
{ | ||
"name": "Luisenblock Ost - Bebauungsplan 1-70", | ||
"identifier": "VI - 123c", | ||
"bplan_id": "VI - 123c", | ||
"description": "Der Luisenblock Ost soll städtebaulich neu geordnet werden. Nutzungen des Deutschen Bundestages sollen in einem Sondergebiet als Auftakt des 'Band des Bundes' zusammengefasst werden.", | ||
"url": "https://berlin.de/ba-marzahn-hellersdorf/.../bebauungsplan.649020.php", | ||
"is_draft": false, | ||
"start_date": "2017-01-01T00:00", | ||
"end_date": "2018-01-01T00:00", | ||
"point": { | ||
"type": "Feature", | ||
"geometry": { | ||
"type": "Point", | ||
"coordinates": [ | ||
13.411924777644563, | ||
52.499598134440944 | ||
] | ||
} | ||
}, | ||
"point": "1492195.544958444,6895923.461738203", | ||
"image_url": "http://berlin.de/images/.../bebauungsplan.649020.png", | ||
"image_copyright": "BA Marzahn-Hellersdorf" | ||
} | ||
|
@@ -185,13 +180,13 @@ curl \ | |
' | ||
{ | ||
"name":"Luisenblock Ost - Bebauungsplan 1-70", | ||
"identifier": "VI - 96a", | ||
"bplan_id": "VI - 96a", | ||
"description": "Test", | ||
"url": "https://mein.berlin.de", | ||
"office_worker_email": "[email protected]", | ||
"start_date": "2019-01-01T00:00", | ||
"end_date": "2022-01-01T00:00", | ||
"point": {"type": "Feature","geometry": {"type": "Point", "coordinates":[13.411924777644563,52.499598134440944]}} | ||
"point": "1492195.544958444,6895923.461738203" | ||
} | ||
' | ||
``` | ||
|
@@ -206,20 +201,22 @@ curl -X POST http://127.0.0.1:8003/api/organisations/1/bplan/ \ | |
' | ||
{ | ||
"name":"Luisenblock Ost - Bebauungsplan 1-70", | ||
"identifier": "VI - 96a", | ||
"bplan_id": "VI - 96a", | ||
"description": "Test", | ||
"url": "https://mein.berlin.de", | ||
"office_worker_email": "[email protected]", | ||
"start_date": "2019-01-01T00:00", | ||
"end_date": "2022-01-01T00:00", | ||
"point": {"type": "Feature","geometry": {"type": "Point", "coordinates":[13.411924777644563,52.499598134440944]}} | ||
"point": "1492195.544958444,6895923.461738203" | ||
} | ||
' | ||
``` | ||
|
||
## Updating a Bplan | ||
|
||
Update an existing Bplan with the id `bplan-id` within the organisation designated by`organisation-id`. | ||
Update an existing Bplan with the id `bplan-id` (attention: `bplan-id` here refers to the id which is returned from | ||
the api after creating a new bplan, not the `bplan_id` field which is used to designate the fis-broker identifier) | ||
within the organisation designated by`organisation-id`. | ||
|
||
**URL** : `https://mein.berlin.de/api/organisations/<organisation-id>/bplan/<bplan-id>/` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -261,8 +261,8 @@ def test_add_bplan_diplan_response_no_embed(apiclient, districts, organisation): | |
"url": "https://bplan.net", | ||
"start_date": "2013-01-01 18:00", | ||
"end_date": "2021-01-01 18:00", | ||
"identifier": "1-234", | ||
"point": "[0,0]", | ||
"bplan_id": "1-234", | ||
"point": "0,0", | ||
} | ||
user = organisation.initiators.first() | ||
apiclient.force_authenticate(user=user) | ||
|
@@ -334,6 +334,29 @@ def test_bplan_api_adds_district_from_identifier(apiclient, districts, organisat | |
assert bplan.administrative_district.name == "Mitte" | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_bplan_api_diplan_adds_district_from_bplan_id( | ||
apiclient, districts, organisation | ||
): | ||
url = reverse("bplan-list", kwargs={"organisation_pk": organisation.pk}) | ||
data = { | ||
"name": "bplan-1", | ||
"description": "desc", | ||
"url": "https://bplan.net", | ||
"office_worker_email": "[email protected]", | ||
"start_date": "2013-01-01 18:00", | ||
"bplan_id": "1-234", | ||
"point": "0,0", | ||
"end_date": "2021-01-01 18:00", | ||
} | ||
user = organisation.initiators.first() | ||
apiclient.force_authenticate(user=user) | ||
response = apiclient.post(url, data, format="json") | ||
assert response.status_code == status.HTTP_201_CREATED | ||
bplan = bplan_models.Bplan.objects.first() | ||
assert bplan.administrative_district.name == "Mitte" | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_bplan_api_adds_district_from_identifier_with_whitespaces( | ||
apiclient, districts, organisation | ||
|
@@ -387,7 +410,7 @@ def test_bplan_api_adds_is_diplan_if_point_is_sent(apiclient, districts, organis | |
"url": "https://bplan.net", | ||
"start_date": "2013-01-01 18:00", | ||
"identifier": "1-234", | ||
"point": "[0,0]", | ||
"point": "0,0", | ||
"end_date": "2021-01-01 18:00", | ||
} | ||
user = organisation.initiators.first() | ||
|
@@ -439,7 +462,7 @@ def test_bplan_api_location_task_not_called_if_point_included( | |
"end_date": "2021-01-01 18:00", | ||
"identifier": "1-234", | ||
"is_published": True, | ||
"point": "[0,0]", | ||
"point": "0,0", | ||
} | ||
user = organisation.initiators.first() | ||
apiclient.force_authenticate(user=user) | ||
|
@@ -449,12 +472,18 @@ def test_bplan_api_location_task_not_called_if_point_included( | |
bplan = bplan_models.Bplan.objects.first() | ||
assert bplan.is_draft is False | ||
assert bplan.is_diplan is True | ||
assert bplan.point == "[0,0]" | ||
assert bplan.point == { | ||
"type": "Feature", | ||
"geometry": { | ||
"type": "Point", | ||
"coordinates": [0.0, 0.0], | ||
}, | ||
} | ||
mock.assert_not_called() | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_bplan_api_accepts_valid_geojson( | ||
def test_bplan_api_accepts_string_as_point_and_converts_to_epsg4326( | ||
apiclient, districts, organisation, django_capture_on_commit_callbacks | ||
): | ||
url = reverse("bplan-list", kwargs={"organisation_pk": organisation.pk}) | ||
|
@@ -466,14 +495,9 @@ def test_bplan_api_accepts_valid_geojson( | |
"end_date": "2021-01-01 18:00", | ||
"identifier": "1-234", | ||
"is_published": True, | ||
"point": { | ||
"type": "Feature", | ||
"geometry": { | ||
"type": "Point", | ||
"coordinates": [13.411924777644563, 52.499598134440944], | ||
}, | ||
}, | ||
"point": "1492195.544958444,6895923.461738203", | ||
} | ||
|
||
user = organisation.initiators.first() | ||
apiclient.force_authenticate(user=user) | ||
with django_capture_on_commit_callbacks(execute=True): | ||
|
@@ -486,6 +510,6 @@ def test_bplan_api_accepts_valid_geojson( | |
"type": "Feature", | ||
"geometry": { | ||
"type": "Point", | ||
"coordinates": [13.411924777644563, 52.499598134440944], | ||
"coordinates": [13.404620649312287, 52.526688152152744], | ||
}, | ||
} |