mirror of
https://github.com/umap-project/umap.git
synced 2025-05-04 21:51:50 +02:00
#3 - First download geo data implementation
This commit is contained in:
parent
0cffe1e174
commit
fcd238c8a3
3 changed files with 21 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -23,3 +23,4 @@ dist/
|
|||
.env
|
||||
.venv/
|
||||
|
||||
.idea
|
||||
|
|
|
@ -80,6 +80,11 @@ i18n_urls += decorated_patterns(
|
|||
views.DataLayerVersion.as_view(),
|
||||
name="datalayer_version",
|
||||
),
|
||||
re_path(
|
||||
r"^datalayer/download/(?P<pk>[\d]+)/(?P<name>[_\w]+.geojson)$",
|
||||
views.DataLayerDownloadVersion.as_view(),
|
||||
name="datalayer_version",
|
||||
),
|
||||
)
|
||||
i18n_urls += decorated_patterns(
|
||||
[ensure_csrf_cookie],
|
||||
|
|
|
@ -721,6 +721,7 @@ class DataLayerView(GZipMixin, BaseDetailView):
|
|||
response = HttpResponse(f.read(), content_type="application/geo+json")
|
||||
response["Last-Modified"] = self.last_modified
|
||||
response["Content-Length"] = statobj.st_size
|
||||
|
||||
return response
|
||||
|
||||
|
||||
|
@ -731,6 +732,20 @@ class DataLayerVersion(DataLayerView):
|
|||
root=settings.MEDIA_ROOT,
|
||||
path=self.object.get_version_path(self.kwargs["name"]),
|
||||
)
|
||||
|
||||
class DataLayerDownloadVersion(DataLayerView):
|
||||
def render_to_response(self, context, **response_kwargs):
|
||||
|
||||
|
||||
filename = os.path.basename(self.path)
|
||||
|
||||
with open(self.path, 'rb') as f:
|
||||
response = HttpResponse(f, content_type='application/geo+json')
|
||||
|
||||
response['Content-Disposition'] = f'attachment; filename="{filename}"'
|
||||
|
||||
return response
|
||||
|
||||
|
||||
|
||||
class DataLayerCreate(FormLessEditMixin, GZipMixin, CreateView):
|
||||
|
|
Loading…
Reference in a new issue