From f8f625214594a4678b077e7b2b56a590ede7ea93 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Tue, 15 Sep 2015 09:01:35 +0200 Subject: [PATCH 3/3] agent/authentic2: do not activate new and old role import at the same time (#8217) --- hobo/agent/authentic2/apps.py | 11 ++++++----- hobo/agent/authentic2/management/commands/import-wcs-roles.py | 3 +++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/hobo/agent/authentic2/apps.py b/hobo/agent/authentic2/apps.py index 321568d..64a7c6a 100644 --- a/hobo/agent/authentic2/apps.py +++ b/hobo/agent/authentic2/apps.py @@ -71,9 +71,10 @@ class Authentic2AgentConfig(AppConfig): verbose_name = 'Authentic2 Agent' def ready(self): - Role = get_role_model() - post_save.connect(notify_roles, Role) - post_delete.connect(notify_roles, Role) - post_save.connect(notify_roles, Role.members.through) - post_delete.connect(notify_roles, Role.members.through) + if getattr(settings, 'HOBO_ROLE_EXPORT', False): + Role = get_role_model() + post_save.connect(notify_roles, Role) + post_delete.connect(notify_roles, Role) + post_save.connect(notify_roles, Role.members.through) + post_delete.connect(notify_roles, Role.members.through) settings.A2_MANAGER_ROLE_FORM_CLASS = 'hobo.agent.authentic2.role_forms.RoleForm' diff --git a/hobo/agent/authentic2/management/commands/import-wcs-roles.py b/hobo/agent/authentic2/management/commands/import-wcs-roles.py index d72f115..d3c12a4 100644 --- a/hobo/agent/authentic2/management/commands/import-wcs-roles.py +++ b/hobo/agent/authentic2/management/commands/import-wcs-roles.py @@ -11,6 +11,7 @@ from optparse import make_option from django.utils.text import slugify from django.core.management.base import BaseCommand from django.utils.translation import ugettext as _ +from django.conf import settings from authentic2.saml.models import LibertyProvider from authentic2.a2_rbac.models import Role, RoleAttribute @@ -137,6 +138,8 @@ class Command(BaseCommand): requires_system_checks = False def handle(self, *args, **options): + if getattr(settings, 'HOBO_ROLE_EXPORT', False): + return # traverse list of tenants for tenant in TenantMiddleware.get_tenants(): with tenant_context(tenant): -- 2.1.4