Skip to content
This repository has been archived by the owner on Jun 1, 2022. It is now read-only.

Commit

Permalink
Exclude soft deleted locations from mapbox API, refs #285
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Apr 15, 2021
1 parent c340bd2 commit 3101d5e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions vaccinate/api/test_mapbox_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

@pytest.mark.django_db
def test_mapbox_export(client, ten_locations):
soft_deleted = ten_locations[3]
soft_deleted.soft_deleted = True
soft_deleted.save()
response = client.get("/api/export-mapbox/Locations.geojson")
joined = b"".join(response.streaming_content)
assert json.loads(joined) == {
Expand All @@ -24,5 +27,6 @@ def test_mapbox_export(client, ten_locations):
"geometry": {"type": "Point", "coordinates": [40.0, 30.0]},
}
for location in ten_locations
if not location.soft_deleted
],
}
2 changes: 2 additions & 0 deletions vaccinate/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,8 @@ def export_mapbox_geojson(request):
location_ids = request.GET.getlist("id")
if location_ids:
locations = locations.filter(public_id__in=location_ids)
else:
locations = locations.exclude(soft_deleted=True)
limit = None
if request.GET.get("limit", "").isdigit():
limit = int(request.GET["limit"])
Expand Down

0 comments on commit 3101d5e

Please sign in to comment.