Download Pathway Functionality (#38)

Co-authored-by: Tim Lorsbach <tim@lorsba.ch>
Reviewed-on: enviPath/enviPy#38
This commit is contained in:
2025-07-31 01:30:16 +12:00
parent aec61151ce
commit 79b4b1586c
5 changed files with 96 additions and 7 deletions

View File

@ -1254,6 +1254,14 @@ def package_pathway(request, package_uuid, pathway_uuid):
if request.GET.get("last_modified", False):
return JsonResponse({'modified': current_pathway.modified.strftime('%Y-%m-%d %H:%M:%S')})
if request.GET.get("download", False) == "true":
filename = f"{current_pathway.name.replace(' ', '_')}_{current_pathway.uuid}.csv"
csv_pw = current_pathway.to_csv()
response = HttpResponse(csv_pw, content_type='text/csv')
response['Content-Disposition'] = f'attachment; filename="{filename}"'
return response
context = get_base_context(request)
context['title'] = f'enviPath - {current_package.name} - {current_pathway.name}'