scripts: add create_authenticators_admin_role (#70958)
This commit is contained in:
parent
fb3e1c530b
commit
b0c81c7934
|
@ -0,0 +1,25 @@
|
|||
import logging
|
||||
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
|
||||
from authentic2.a2_rbac.models import Role
|
||||
from authentic2.apps.authenticators.models import BaseAuthenticator
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
try:
|
||||
admin_role = Role.objects.get(slug='_a2-manager')
|
||||
except Role.DoesNotExist:
|
||||
logger.warning('No admin role.')
|
||||
else:
|
||||
content_type = ContentType.objects.get_for_model(BaseAuthenticator)
|
||||
role = Role.objects.get_admin_role(
|
||||
instance=content_type,
|
||||
slug='_a2-manager-of-authenticators',
|
||||
name='Administrateur des moyens d’authentification',
|
||||
update_name=True,
|
||||
update_slug=True,
|
||||
create=True,
|
||||
)
|
||||
role.add_child(admin_role)
|
Loading…
Reference in New Issue