Merge "Fix project name refresh in project menu bar"
This commit is contained in:
commit
c3f9e8beaa
@ -63,7 +63,7 @@ class ImagesViewTest(test.BaseAdminViewTests):
|
||||
|
||||
res = self.client.get(
|
||||
reverse('horizon:admin:images:index'))
|
||||
self.assertContains(res, 'test_tenant', 8, 200)
|
||||
self.assertContains(res, 'test_tenant', 9, 200)
|
||||
self.assertTemplateUsed(res, 'admin/images/index.html')
|
||||
self.assertEqual(len(res.context['images_table'].data),
|
||||
len(self.images.list()))
|
||||
@ -111,7 +111,7 @@ class ImagesViewTest(test.BaseAdminViewTests):
|
||||
self.assertEqual(len(res.context['images_table'].data),
|
||||
len(images))
|
||||
self.assertTemplateUsed(res, 'admin/images/index.html')
|
||||
self.assertContains(res, 'test_tenant', 6, 200)
|
||||
self.assertContains(res, 'test_tenant', 7, 200)
|
||||
|
||||
res = self.client.get(url)
|
||||
# get first page with 2 items
|
||||
@ -125,7 +125,7 @@ class ImagesViewTest(test.BaseAdminViewTests):
|
||||
# get second page (items 2-4)
|
||||
self.assertEqual(len(res.context['images_table'].data),
|
||||
settings.API_RESULT_PAGE_SIZE)
|
||||
self.assertContains(res, 'test_tenant', 3, 200)
|
||||
self.assertContains(res, 'test_tenant', 4, 200)
|
||||
|
||||
params = "=".join([tables.AdminImagesTable._meta.pagination_param,
|
||||
images[4].id])
|
||||
@ -134,7 +134,7 @@ class ImagesViewTest(test.BaseAdminViewTests):
|
||||
# get third page (item 5)
|
||||
self.assertEqual(len(res.context['images_table'].data),
|
||||
1)
|
||||
self.assertContains(res, 'test_tenant', 2, 200)
|
||||
self.assertContains(res, 'test_tenant', 3, 200)
|
||||
|
||||
@override_settings(API_RESULT_PAGE_SIZE=2)
|
||||
@test.create_stubs({api.glance: ('image_list_detailed',),
|
||||
@ -175,13 +175,13 @@ class ImagesViewTest(test.BaseAdminViewTests):
|
||||
self.assertEqual(len(res.context['images_table'].data),
|
||||
len(images))
|
||||
self.assertTemplateUsed(res, 'admin/images/index.html')
|
||||
self.assertContains(res, 'test_tenant', 4, 200)
|
||||
self.assertContains(res, 'test_tenant', 5, 200)
|
||||
|
||||
res = self.client.get(url)
|
||||
# get first page with 2 items
|
||||
self.assertEqual(len(res.context['images_table'].data),
|
||||
settings.API_RESULT_PAGE_SIZE)
|
||||
self.assertContains(res, 'test_tenant', 3, 200)
|
||||
self.assertContains(res, 'test_tenant', 4, 200)
|
||||
|
||||
params = "=".join([tables.AdminImagesTable._meta.pagination_param,
|
||||
images[2].id])
|
||||
@ -189,7 +189,7 @@ class ImagesViewTest(test.BaseAdminViewTests):
|
||||
res = self.client.get(url)
|
||||
# get second page (item 3)
|
||||
self.assertEqual(len(res.context['images_table'].data), 1)
|
||||
self.assertContains(res, 'test_tenant', 2, 200)
|
||||
self.assertContains(res, 'test_tenant', 3, 200)
|
||||
|
||||
params = "=".join([tables.AdminImagesTable._meta.prev_pagination_param,
|
||||
images[2].id])
|
||||
@ -198,4 +198,4 @@ class ImagesViewTest(test.BaseAdminViewTests):
|
||||
# prev back to get first page with 2 items
|
||||
self.assertEqual(len(res.context['images_table'].data),
|
||||
settings.API_RESULT_PAGE_SIZE)
|
||||
self.assertContains(res, 'test_tenant', 3, 200)
|
||||
self.assertContains(res, 'test_tenant', 4, 200)
|
||||
|
@ -52,9 +52,12 @@ def show_overview(context):
|
||||
if 'request' not in context:
|
||||
return {}
|
||||
request = context['request']
|
||||
project_name = get_project_name(request.user.project_id,
|
||||
context['authorized_tenants'])
|
||||
|
||||
context = {'domain_supported': is_multidomain_supported(),
|
||||
'domain_name': request.user.user_domain_name,
|
||||
'project_name': request.user.project_name,
|
||||
'project_name': project_name or request.user.project_name,
|
||||
'multi_region': is_multi_region_configured(request),
|
||||
'region_name': request.user.services_region,
|
||||
'request': request}
|
||||
@ -110,3 +113,15 @@ def iframe_embed_settings(context):
|
||||
True)
|
||||
context = {'disallow_iframe_embed': disallow_iframe_embed}
|
||||
return context
|
||||
|
||||
|
||||
def get_project_name(project_id, projects):
|
||||
"""Retrieves project name for given project id
|
||||
Args:
|
||||
projects: List of projects
|
||||
project_id: project id
|
||||
Returns: Project name or None if there is no match
|
||||
"""
|
||||
for project in projects:
|
||||
if project_id == project.id:
|
||||
return project.name
|
||||
|
Loading…
Reference in New Issue
Block a user