From a47c9846234843884e2d7455265237ff23c09d89 Mon Sep 17 00:00:00 2001 From: Vlad Okhrimenko Date: Wed, 26 Nov 2014 16:40:48 +0200 Subject: [PATCH] Update project list in the header bar. Use function for clean cache (from openstack_auth), after project members were changed(for project cache is invalidated). Now, in the header bar, show only active projects. Change-Id: Ia2561b591b4f3de29a14aaa4b666b16fc1d4cec8 Closes-Bug: #1393659 --- openstack_dashboard/context_processors.py | 4 +++- .../dashboards/identity/projects/tables.py | 8 ++++++++ .../dashboards/identity/projects/workflows.py | 6 ++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/openstack_dashboard/context_processors.py b/openstack_dashboard/context_processors.py index 0361b9f596..d58fc360db 100644 --- a/openstack_dashboard/context_processors.py +++ b/openstack_dashboard/context_processors.py @@ -40,7 +40,9 @@ def openstack(request): # Auth/Keystone context context.setdefault('authorized_tenants', []) if request.user.is_authenticated(): - context['authorized_tenants'] = request.user.authorized_tenants + context['authorized_tenants'] = [ + tenant for tenant in + request.user.authorized_tenants if tenant.enabled] # Region context/support available_regions = getattr(settings, 'AVAILABLE_REGIONS', []) diff --git a/openstack_dashboard/dashboards/identity/projects/tables.py b/openstack_dashboard/dashboards/identity/projects/tables.py index 126fbdf274..02977253bb 100644 --- a/openstack_dashboard/dashboards/identity/projects/tables.py +++ b/openstack_dashboard/dashboards/identity/projects/tables.py @@ -16,6 +16,8 @@ from django.utils.http import urlencode from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ungettext_lazy +from openstack_auth import utils as auth_utils + from horizon import exceptions from horizon import forms from horizon import tables @@ -155,6 +157,12 @@ class DeleteTenantsAction(tables.DeleteAction): def delete(self, request, obj_id): api.keystone.tenant_delete(request, obj_id) + def handle(self, table, request, obj_ids): + response = \ + super(DeleteTenantsAction, self).handle(table, request, obj_ids) + auth_utils.remove_project_cache(request.user.token.id) + return response + class TenantFilterAction(tables.FilterAction): def filter(self, table, tenants, filter_string): diff --git a/openstack_dashboard/dashboards/identity/projects/workflows.py b/openstack_dashboard/dashboards/identity/projects/workflows.py index 73a421d3e1..54b0007afb 100644 --- a/openstack_dashboard/dashboards/identity/projects/workflows.py +++ b/openstack_dashboard/dashboards/identity/projects/workflows.py @@ -21,6 +21,8 @@ from django.conf import settings from django.core.urlresolvers import reverse from django.utils.translation import ugettext_lazy as _ +from openstack_auth import utils as auth_utils + from horizon import exceptions from horizon import forms from horizon import messages @@ -444,6 +446,8 @@ class CreateProject(workflows.Workflow): 'members%(group_msg)s and set project quotas.') % {'users_to_add': users_to_add, 'group_msg': group_msg}) + finally: + auth_utils.remove_project_cache(request.user.token.id) def _update_project_groups(self, request, data, project_id): # update project groups @@ -697,6 +701,8 @@ class UpdateProject(workflows.Workflow): % {'users_to_modify': users_to_modify, 'group_msg': group_msg}) return False + finally: + auth_utils.remove_project_cache(request.user.token.id) def _update_project_groups(self, request, data, project_id, domain_id): # update project groups