fix: Path.replace called instead str.replace

This commit is contained in:
Yohan Boniface 2024-03-25 14:40:48 +01:00
parent 8d9468df00
commit 288c7983fc
4 changed files with 17 additions and 3 deletions

View file

@ -1,5 +1,9 @@
# Changelog
## 2.1.1 - 2024-03-25
- fix Path.replace called instead of str.replace
## 2.1.0 - 2024-03-25
### Bug fixes

View file

@ -1 +1 @@
VERSION = "2.1.0"
VERSION = "2.1.1"

View file

@ -44,6 +44,16 @@ def test_get_with_public_mode(client, settings, datalayer, map):
assert j["type"] == "FeatureCollection"
def test_get_with_x_accel_redirect(client, settings, datalayer, map):
settings.UMAP_XSENDFILE_HEADER = "X-Accel-Redirect"
url = reverse("datalayer_view", args=(map.pk, datalayer.pk))
response = client.get(url)
assert response.status_code == 200
assert "X-Accel-Redirect" in response.headers
assert response["X-Accel-Redirect"].startswith("/internal/datalayer/")
assert response["X-Accel-Redirect"].endswith(".geojson")
def test_get_with_open_mode(client, settings, datalayer, map):
map.share_status = Map.PUBLIC
map.save()

View file

@ -1020,8 +1020,8 @@ class DataLayerView(GZipMixin, BaseDetailView):
if getattr(settings, "UMAP_XSENDFILE_HEADER", None):
response = HttpResponse()
path = path.replace(settings.MEDIA_ROOT, "/internal")
response[settings.UMAP_XSENDFILE_HEADER] = path
internal_path = str(path).replace(settings.MEDIA_ROOT, "/internal")
response[settings.UMAP_XSENDFILE_HEADER] = internal_path
else:
# Do not use in production
# (no gzip/cache-control/If-Modified-Since/If-None-Match)