From 2cdd0bb20e9dbf217627462d49ffb9ac1bf829ab Mon Sep 17 00:00:00 2001 From: Rob Raymond Date: Wed, 25 Sep 2013 16:42:04 -0600 Subject: [PATCH] Allow region override for url_for If region is passed in to url_for use that, otherwise continue to use the region from the user's session. Fixes bug #1231171 Change-Id: Ia7d2a4f12a3c0d4d45bb918255184d1736f5bddf --- openstack_dashboard/api/base.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/openstack_dashboard/api/base.py b/openstack_dashboard/api/base.py index 5cb61999ad..b4735795f4 100644 --- a/openstack_dashboard/api/base.py +++ b/openstack_dashboard/api/base.py @@ -247,7 +247,7 @@ def get_url_for_service(service, region, endpoint_type): return None -def url_for(request, service_type, endpoint_type=None): +def url_for(request, service_type, endpoint_type=None, region=None): endpoint_type = endpoint_type or getattr(settings, 'OPENSTACK_ENDPOINT_TYPE', 'publicURL') @@ -256,12 +256,14 @@ def url_for(request, service_type, endpoint_type=None): catalog = request.user.service_catalog service = get_service_from_catalog(catalog, service_type) if service: + if not region: + region = request.user.services_region url = get_url_for_service(service, - request.user.services_region, + region, endpoint_type) if not url and fallback_endpoint_type: url = get_url_for_service(service, - request.user.services_region, + region, fallback_endpoint_type) if url: return url