summaryrefslogtreecommitdiffstats
path: root/grandlyon/scripts/mark-admin-roles.py
blob: 66afc581e1954a1fa13e4758df0a6b8a64b831dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 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 Genais

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()

name_dst = sys.argv[1]
ou = Ou.objects.get(name=name_dst)

role = Role.objects.get(name=u'Administrateur %s' % name_dst, ou=ou)
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)