Skip to content

Commit

Permalink
geojson: Show error messages correctly. Allow .geojson files.
Browse files Browse the repository at this point in the history
  • Loading branch information
jarofgreen committed Nov 7, 2022
1 parent 4949920 commit fa778fb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions cove_ofds/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion cove_project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

0 comments on commit fa778fb

Please sign in to comment.