Browse Source

Conserta criação de ususários padrão

pull/1674/head
Marcio Mazza 7 years ago
parent
commit
04a143c27e
  1. 31
      sapl/rules/apps.py

31
sapl/rules/apps.py

@ -1,15 +1,15 @@
from builtins import LookupError from builtins import LookupError
import django
import reversion
from django.apps import apps from django.apps import apps
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.contrib.auth.management import _get_all_permissions from django.contrib.auth.management import _get_all_permissions
from django.core import exceptions from django.core import exceptions
from django.db import models, router from django.db import models, router
from django.db.utils import DEFAULT_DB_ALIAS from django.db.utils import DEFAULT_DB_ALIAS
from django.utils.translation import string_concat
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
import django from django.utils.translation import string_concat
import reversion
from sapl.rules import (SAPL_GROUP_ADMINISTRATIVO, SAPL_GROUP_COMISSOES, from sapl.rules import (SAPL_GROUP_ADMINISTRATIVO, SAPL_GROUP_COMISSOES,
SAPL_GROUP_GERAL, SAPL_GROUP_MATERIA, SAPL_GROUP_NORMA, SAPL_GROUP_GERAL, SAPL_GROUP_MATERIA, SAPL_GROUP_NORMA,
@ -126,12 +126,7 @@ def create_proxy_permissions(
print("Adding permission '%s'" % perm) print("Adding permission '%s'" % perm)
def update_groups(app_config, verbosity=2, interactive=True, def get_rules():
using=DEFAULT_DB_ALIAS, cria_usuarios_padrao=False,
**kwargs):
if app_config != AppConfig and not isinstance(app_config, AppConfig):
return
from sapl.rules.map_rules import rules_patterns from sapl.rules.map_rules import rules_patterns
from django.contrib.auth.models import Group, Permission from django.contrib.auth.models import Group, Permission
@ -224,10 +219,22 @@ def update_groups(app_config, verbosity=2, interactive=True,
rules_list = rules_group['rules'] rules_list = rules_group['rules']
self._config_group(group_name, rules_list) self._config_group(group_name, rules_list)
rules = Rules(rules_patterns) return Rules(rules_patterns)
def update_groups(app_config, verbosity=2, interactive=True,
using=DEFAULT_DB_ALIAS, **kwargs):
if app_config != AppConfig and not isinstance(app_config, AppConfig):
return
rules = get_rules()
rules.update_groups() rules.update_groups()
if cria_usuarios_padrao:
rules.cria_usuarios_padrao()
def cria_usuarios_padrao():
rules = get_rules()
rules.cria_usuarios_padrao()
def revision_pre_delete_signal(sender, **kwargs): def revision_pre_delete_signal(sender, **kwargs):

Loading…
Cancel
Save