Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: James McKinney <[email protected]>
  • Loading branch information
yolile and jpmckinney authored Nov 10, 2023
1 parent af64b79 commit 005d568
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions data_registry/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,20 +177,14 @@ def spiders(request):


def download_export(request, id):
"""
Returns an exported file as a FileResponse object.
"""
name = request.GET.get("name")

# Guard against path traversal.
if not EXPORT_PATTERN.match(name):
return HttpResponseBadRequest("The name query string parameter is invalid")

collection = get_object_or_404(collection_queryset(request), id=id)

active_job = collection.job.filter(active=True).first()
if not active_job:
return HttpResponseNotFound("This OCDS dataset is not available for download")
active_job = get_object_or_404(collection.job, active=True)

export = Export(active_job.id, basename=name)
if export.status != TaskStatus.COMPLETED:
Expand Down

0 comments on commit 005d568

Please sign in to comment.