summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRadomir Dopieralski <openstack@sheep.art.pl>2017-01-31 13:01:51 +0100
committerRichard Jones <r1chardj0n3s@gmail.com>2017-02-16 16:23:02 +1100
commit30d0a31d41340d0ad340d12db3455156b04e71fc (patch)
treeceab11c0819eecb5d73fb82472b3e772db10b743
parent1227d3eb1407c03e0005cdf8c705d86189491cbd (diff)
Use domain_context not effective domain to display domains list11.0.0.0rc211.0.0
Use domain_context to decide whether to call domain_list or domain_get in the list of domains. Previous code used the user's effective domain instead, which is no longer the same thing with Keystone V3. Closes-Bug: #1660602 Change-Id: Ie410d282c5b19a061fe83b496785f35bbcfad9ad (cherry picked from commit 1be065aed8e330c746f85f9600d2c60c4478a661)
Notes
Notes (review): Code-Review+2: Rob Cresswell <robert.cresswell@outlook.com> Workflow+1: Rob Cresswell <robert.cresswell@outlook.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Thu, 16 Feb 2017 06:25:20 +0000 Reviewed-on: https://review.openstack.org/434656 Project: openstack/horizon Branch: refs/heads/stable/ocata
-rw-r--r--openstack_dashboard/dashboards/identity/domains/tests.py8
-rw-r--r--openstack_dashboard/dashboards/identity/domains/views.py19
2 files changed, 9 insertions, 18 deletions
diff --git a/openstack_dashboard/dashboards/identity/domains/tests.py b/openstack_dashboard/dashboards/identity/domains/tests.py
index 96524ac..79b19c0 100644
--- a/openstack_dashboard/dashboards/identity/domains/tests.py
+++ b/openstack_dashboard/dashboards/identity/domains/tests.py
@@ -39,8 +39,6 @@ class DomainsViewTests(test.BaseAdminViewTests):
39 @test.create_stubs({api.keystone: ('domain_get', 39 @test.create_stubs({api.keystone: ('domain_get',
40 'domain_list',)}) 40 'domain_list',)})
41 def test_index(self): 41 def test_index(self):
42 domain = self.domains.get(id="1")
43 api.keystone.domain_get(IsA(http.HttpRequest), '1').AndReturn(domain)
44 api.keystone.domain_list(IgnoreArg()).AndReturn(self.domains.list()) 42 api.keystone.domain_list(IgnoreArg()).AndReturn(self.domains.list())
45 43
46 self.mox.ReplayAll() 44 self.mox.ReplayAll()
@@ -59,8 +57,6 @@ class DomainsViewTests(test.BaseAdminViewTests):
59 'domain_list', 57 'domain_list',
60 'keystone_can_edit_domain')}) 58 'keystone_can_edit_domain')})
61 def test_index_with_keystone_can_edit_domain_false(self): 59 def test_index_with_keystone_can_edit_domain_false(self):
62 domain = self.domains.get(id="1")
63 api.keystone.domain_get(IsA(http.HttpRequest), '1').AndReturn(domain)
64 api.keystone.domain_list(IgnoreArg()).AndReturn(self.domains.list()) 60 api.keystone.domain_list(IgnoreArg()).AndReturn(self.domains.list())
65 api.keystone.keystone_can_edit_domain() \ 61 api.keystone.keystone_can_edit_domain() \
66 .MultipleTimes().AndReturn(False) 62 .MultipleTimes().AndReturn(False)
@@ -83,7 +79,6 @@ class DomainsViewTests(test.BaseAdminViewTests):
83 def test_delete_domain(self): 79 def test_delete_domain(self):
84 domain = self.domains.get(id="2") 80 domain = self.domains.get(id="2")
85 81
86 api.keystone.domain_get(IsA(http.HttpRequest), '2').AndReturn(domain)
87 api.keystone.domain_list(IgnoreArg()).AndReturn(self.domains.list()) 82 api.keystone.domain_list(IgnoreArg()).AndReturn(self.domains.list())
88 api.keystone.domain_delete(IgnoreArg(), domain.id) 83 api.keystone.domain_delete(IgnoreArg(), domain.id)
89 84
@@ -99,7 +94,6 @@ class DomainsViewTests(test.BaseAdminViewTests):
99 def test_delete_with_enabled_domain(self): 94 def test_delete_with_enabled_domain(self):
100 domain = self.domains.get(id="1") 95 domain = self.domains.get(id="1")
101 96
102 api.keystone.domain_get(IsA(http.HttpRequest), '1').AndReturn(domain)
103 api.keystone.domain_list(IgnoreArg()).AndReturn(self.domains.list()) 97 api.keystone.domain_list(IgnoreArg()).AndReturn(self.domains.list())
104 98
105 self.mox.ReplayAll() 99 self.mox.ReplayAll()
@@ -116,7 +110,6 @@ class DomainsViewTests(test.BaseAdminViewTests):
116 def test_disable(self): 110 def test_disable(self):
117 domain = self.domains.get(id="1") 111 domain = self.domains.get(id="1")
118 112
119 api.keystone.domain_get(IsA(http.HttpRequest), '1').AndReturn(domain)
120 api.keystone.domain_list(IgnoreArg()).AndReturn(self.domains.list()) 113 api.keystone.domain_list(IgnoreArg()).AndReturn(self.domains.list())
121 api.keystone.domain_update(IsA(http.HttpRequest), 114 api.keystone.domain_update(IsA(http.HttpRequest),
122 description=domain.description, 115 description=domain.description,
@@ -138,7 +131,6 @@ class DomainsViewTests(test.BaseAdminViewTests):
138 def test_enable(self): 131 def test_enable(self):
139 domain = self.domains.get(id="2") 132 domain = self.domains.get(id="2")
140 133
141 api.keystone.domain_get(IsA(http.HttpRequest), '1').AndReturn(domain)
142 api.keystone.domain_list(IgnoreArg()).AndReturn(self.domains.list()) 134 api.keystone.domain_list(IgnoreArg()).AndReturn(self.domains.list())
143 api.keystone.domain_update(IsA(http.HttpRequest), 135 api.keystone.domain_update(IsA(http.HttpRequest),
144 description=domain.description, 136 description=domain.description,
diff --git a/openstack_dashboard/dashboards/identity/domains/views.py b/openstack_dashboard/dashboards/identity/domains/views.py
index b1301cf..c3914fa 100644
--- a/openstack_dashboard/dashboards/identity/domains/views.py
+++ b/openstack_dashboard/dashboards/identity/domains/views.py
@@ -38,22 +38,21 @@ class IndexView(tables.DataTableView):
38 38
39 def get_data(self): 39 def get_data(self):
40 domains = [] 40 domains = []
41 domain_id = identity.get_domain_id_for_operation(self.request) 41 domain_context = self.request.session.get('domain_context')
42 42
43 if policy.check((("identity", "identity:list_domains"),), 43 if policy.check((
44 self.request): 44 ("identity", "identity:list_domains"),
45 ), self.request) and not domain_context:
45 try: 46 try:
46 if domain_id: 47 domains = api.keystone.domain_list(self.request)
47 domain = api.keystone.domain_get(self.request, domain_id)
48 domains.append(domain)
49 else:
50 domains = api.keystone.domain_list(self.request)
51 except Exception: 48 except Exception:
52 exceptions.handle(self.request, 49 exceptions.handle(self.request,
53 _('Unable to retrieve domain list.')) 50 _('Unable to retrieve domain list.'))
54 elif policy.check((("identity", "identity:get_domain"),), 51 elif policy.check((
55 self.request): 52 ("identity", "identity:get_domain"),
53 ), self.request):
56 try: 54 try:
55 domain_id = identity.get_domain_id_for_operation(self.request)
57 domain = api.keystone.domain_get(self.request, domain_id) 56 domain = api.keystone.domain_get(self.request, domain_id)
58 domains.append(domain) 57 domains.append(domain)
59 except Exception: 58 except Exception: