From 2f76bac3a1082e98f5ae37657fc34ef6d3894882 Mon Sep 17 00:00:00 2001 From: Akihiro Motoki Date: Thu, 6 Apr 2017 18:47:34 +0000 Subject: [PATCH] Strip blank lines from downloaded clouds.yaml file There are a lot of blank lines in clouds.yaml downloaded from horizon. This is as a result of rendering Django templates. This commit stripped blank lines from the rendered content. The logic was kept. You can see the detail logic in django.shortcuts.render(). Change-Id: Ie5b0652adead671823b81a8de8958638a3058eb2 Closes-Bug: #1680558 --- .../dashboards/project/api_access/views.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/openstack_dashboard/dashboards/project/api_access/views.py b/openstack_dashboard/dashboards/project/api_access/views.py index ab7b99542f..9456f63384 100644 --- a/openstack_dashboard/dashboards/project/api_access/views.py +++ b/openstack_dashboard/dashboards/project/api_access/views.py @@ -171,10 +171,11 @@ def download_clouds_yaml_file(request): def _download_rc_file_for_template(request, context, template, filename=None): try: - response = shortcuts.render(request, - template, - context, - content_type="text/plain") + content = render_to_string(template, context, request=request) + content = '\n'.join([line for line in content.split('\n') + if line.strip()]) + response = http.HttpResponse(content, content_type="text/plain") + if not filename: filename = '%s-openrc.sh' % context['tenant_name'] disposition = 'attachment; filename="%s"' % filename