From fa778fbef084205708d902beef5f0650abb07267 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 7 Nov 2022 09:14:04 +0000 Subject: [PATCH] geojson: Show error messages correctly. Allow .geojson files. https://github.com/Open-Telecoms-Data/cove-ofds/issues/5#issuecomment-1304923663 --- cove_ofds/views.py | 4 ++-- cove_project/settings.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cove_ofds/views.py b/cove_ofds/views.py index b03af1f..340590b 100644 --- a/cove_ofds/views.py +++ b/cove_ofds/views.py @@ -50,13 +50,13 @@ def new_geojson(request): not request.FILES[field].content_type in settings.ALLOWED_GEOJSON_CONTENT_TYPES ): - form.add_error("file_upload", "This does not appear to be a JSON file") + form.add_error(field, "This does not appear to be a JSON file") if not [ e for e in settings.ALLOWED_GEOJSON_EXTENSIONS if str(request.FILES[field].name).lower().endswith(e) ]: - form.add_error("file_upload", "This does not appear to be a JSON file") + form.add_error(field, "This does not appear to be a JSON file") # Process if form.is_valid(): diff --git a/cove_project/settings.py b/cove_project/settings.py index e2556fb..8a96d98 100644 --- a/cove_project/settings.py +++ b/cove_project/settings.py @@ -161,4 +161,4 @@ ALLOWED_GEOJSON_CONTENT_TYPES = settings.ALLOWED_JSON_CONTENT_TYPES + [ "application/geo+json" ] -ALLOWED_GEOJSON_EXTENSIONS = settings.ALLOWED_JSON_EXTENSIONS +ALLOWED_GEOJSON_EXTENSIONS = settings.ALLOWED_JSON_EXTENSIONS + [".geojson"]