misc-vdeniaud/scripts/authentic/create_authenticators_admin...

25 lines
716 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import logging
from authentic2.a2_rbac.models import Role
from authentic2.apps.authenticators.models import BaseAuthenticator
from django.contrib.contenttypes.models import ContentType
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 dauthentification',
update_name=True,
update_slug=True,
create=True,
)
role.add_child(admin_role)