grandlyon: script to add all technical admin roles to "Administrateur <commune>"
This commit is contained in:
parent
7055bf02a7
commit
f8f1b4f26b
|
@ -0,0 +1,24 @@
|
|||
# add all collectivity technical admin roles to "Administrateur <commune>"
|
||||
|
||||
# authentic2-multitenant-manage tenant_command runscript -d connexion.guichet-recette.grandlyon.com ~tma/misc-fred/grandlyon/scripts/mark-admin-roles.py
|
||||
|
||||
import os
|
||||
import json
|
||||
import sys
|
||||
|
||||
from django.db.models.query import Q
|
||||
|
||||
from django_rbac.utils import get_role_model, get_ou_model
|
||||
|
||||
Ou = get_ou_model()
|
||||
Role = get_role_model()
|
||||
|
||||
communes_json = os.path.join(os.path.dirname(__file__), 'communes.json')
|
||||
|
||||
for dest in json.load(open(communes_json))['dests']:
|
||||
ou = Ou.objects.get(name=dest['name'])
|
||||
role = Role.objects.get(name=u'Administrateur %s' % dest['name'])
|
||||
for subrole in Role.objects.filter(Q(slug='_a2-hobo-superuser', ou=ou) |
|
||||
Q(slug__startswith='administrateur-fonc', ou=ou) |
|
||||
Q(slug__startswith='_a2-administrateur', ou=ou)):
|
||||
role.add_parent(subrole)
|
Loading…
Reference in New Issue