forked from enviPath/enviPy
Download Pathway Functionality (#38)
Co-authored-by: Tim Lorsbach <tim@lorsba.ch> Reviewed-on: enviPath/enviPy#38
This commit is contained in:
@ -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}'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user