def download_all(request): """Download the database.""" zip_file = save_dfs_get_zip() name = datetime.now().strftime("%Y_%m_%d_%H_%M_%S") out_zip = f'database_tournesol_{name}.zip' response = HttpResponse(zip_file.read(), content_type='application/zip') response['Content-Disposition'] = 'attachment; filename=%s' % out_zip response['X-Sendfile'] = out_zip del zip_file return response
def download_user_data(request): """Download the database.""" username = request.user.username zip_file = save_dfs_get_zip( dfs_fcn=partial(get_user_data, username=username)) name = datetime.now().strftime("%Y_%m_%d_%H_%M_%S") out_zip = f'tournesol_{username}_{name}.zip' response = HttpResponse(zip_file.read(), content_type='application/zip') response['Content-Disposition'] = 'attachment; filename=%s' % out_zip response['X-Sendfile'] = out_zip del zip_file return response