diff --git a/sapl/base/forms.py b/sapl/base/forms.py index 8a28dabbe..4334f7e94 100644 --- a/sapl/base/forms.py +++ b/sapl/base/forms.py @@ -12,32 +12,12 @@ from sapl.crispy_layout_mixin import form_actions, to_row from sapl.materia.models import MateriaLegislativa from sapl.sessao.models import SessaoPlenaria from sapl.settings import MAX_IMAGE_UPLOAD_SIZE -from sapl.utils import (RANGE_ANOS, ImageThumbnailFileInput, autor_label, - autor_modal) +from sapl.utils import (RANGE_ANOS, ImageThumbnailFileInput, + RangeWidgetOverride, autor_label, autor_modal) from .models import AppConfig, CasaLegislativa -class RangeWidgetOverride(forms.MultiWidget): - - def __init__(self, attrs=None): - widgets = (forms.DateInput(format='%d/%m/%Y', - attrs={'class': 'dateinput', - 'placeholder': 'Inicial'}), - forms.DateInput(format='%d/%m/%Y', - attrs={'class': 'dateinput', - 'placeholder': 'Final'})) - super(RangeWidgetOverride, self).__init__(widgets, attrs) - - def decompress(self, value): - if value: - return [value.start, value.stop] - return [None, None] - - def format_output(self, rendered_widgets): - return ''.join(rendered_widgets) - - class RelatorioAtasFilterSet(django_filters.FilterSet): filter_overrides = {models.DateField: { @@ -53,7 +33,7 @@ class RelatorioAtasFilterSet(django_filters.FilterSet): def __init__(self, *args, **kwargs): super(RelatorioAtasFilterSet, self).__init__( - *args, **kwargs) + *args, **kwargs) self.filters['data_inicio'].label = 'Período (Inicial - Final)' self.form.fields['data_inicio'].required = True @@ -83,7 +63,7 @@ class RelatorioPresencaSessaoFilterSet(django_filters.FilterSet): def __init__(self, *args, **kwargs): super(RelatorioPresencaSessaoFilterSet, self).__init__( - *args, **kwargs) + *args, **kwargs) self.filters['data_inicio'].label = 'Período (Inicial - Final)' self.form.fields['data_inicio'].required = True @@ -114,7 +94,7 @@ class RelatorioHistoricoTramitacaoFilterSet(django_filters.FilterSet): def __init__(self, *args, **kwargs): super(RelatorioHistoricoTramitacaoFilterSet, self).__init__( - *args, **kwargs) + *args, **kwargs) self.filters['tipo'].label = 'Tipo de Matéria' @@ -146,7 +126,7 @@ class RelatorioMateriasTramitacaoilterSet(django_filters.FilterSet): def __init__(self, *args, **kwargs): super(RelatorioMateriasTramitacaoilterSet, self).__init__( - *args, **kwargs) + *args, **kwargs) self.filters['tipo'].label = 'Tipo de Matéria' @@ -287,6 +267,7 @@ class LoginForm(AuthenticationForm): class ConfiguracoesAppForm(ModelForm): + class Meta: model = AppConfig fields = ['documentos_administrativos', diff --git a/sapl/materia/forms.py b/sapl/materia/forms.py index 81063456d..fe36a2c29 100644 --- a/sapl/materia/forms.py +++ b/sapl/materia/forms.py @@ -1,9 +1,9 @@ from datetime import datetime -import django_filters from crispy_forms.helper import FormHelper from crispy_forms.layout import HTML, Button, Column, Fieldset, Layout from django import forms +from django.contrib.auth import get_user_model from django.contrib.auth.models import Group, User from django.contrib.auth.password_validation import validate_password from django.core.exceptions import ObjectDoesNotExist, ValidationError @@ -11,19 +11,22 @@ from django.db import models, transaction from django.db.models import Max from django.forms import ModelForm from django.utils.translation import ugettext_lazy as _ +import django_filters from sapl.comissoes.models import Comissao from sapl.crispy_layout_mixin import form_actions, to_row from sapl.norma.models import (LegislacaoCitada, NormaJuridica, TipoNormaJuridica) from sapl.settings import MAX_DOC_UPLOAD_SIZE -from sapl.utils import RANGE_ANOS, autor_label, autor_modal +from sapl.utils import (RANGE_ANOS, RangeWidgetOverride, autor_label, + autor_modal) from .models import (AcompanhamentoMateria, Anexada, Autor, Autoria, DespachoInicial, DocumentoAcessorio, MateriaLegislativa, Numeracao, Proposicao, Relatoria, TipoMateriaLegislativa, Tramitacao, UnidadeTramitacao) + ANO_CHOICES = [('', '---------')] + RANGE_ANOS @@ -34,6 +37,7 @@ def em_tramitacao(): class ConfirmarProposicaoForm(ModelForm): + class Meta: model = Proposicao exclude = ['texto_original', 'descricao', 'tipo'] @@ -247,7 +251,7 @@ class TramitacaoForm(ModelForm): raise ValidationError(msg) if (ultima_tramitacao and - data_tram_form < ultima_tramitacao.data_tramitacao): + data_tram_form < ultima_tramitacao.data_tramitacao): msg = _('A data da nova tramitação deve ser ' + 'maior que a data da última tramitação!') raise ValidationError(msg) @@ -445,26 +449,6 @@ class AnexadaForm(ModelForm): fields = ['tipo', 'numero', 'ano', 'data_anexacao', 'data_desanexacao'] -class RangeWidgetOverride(forms.MultiWidget): - - def __init__(self, attrs=None): - widgets = (forms.DateInput(format='%d/%m/%Y', - attrs={'class': 'dateinput', - 'placeholder': 'Inicial'}), - forms.DateInput(format='%d/%m/%Y', - attrs={'class': 'dateinput', - 'placeholder': 'Final'})) - super(RangeWidgetOverride, self).__init__(widgets, attrs) - - def decompress(self, value): - if value: - return [value.start, value.stop] - return [None, None] - - def format_output(self, rendered_widgets): - return ''.join(rendered_widgets) - - class MateriaLegislativaFilterSet(django_filters.FilterSet): filter_overrides = {models.DateField: { @@ -688,11 +672,11 @@ class AutorForm(ModelForm): return True def valida_email_existente(self): - return User.objects.filter( + return get_user_model().objects.filter( email=self.cleaned_data['email']).exists() def usuario_existente(self): - return User.objects.filter( + return get_user_model().objects.filter( username=self.cleaned_data['username']).exists() def clean(self): diff --git a/sapl/materia/models.py b/sapl/materia/models.py index ac179f714..50bbd000b 100644 --- a/sapl/materia/models.py +++ b/sapl/materia/models.py @@ -1,4 +1,4 @@ -from django.contrib.auth.models import Group, User +from django.contrib.auth.models import Group from django.db import models from django.utils.translation import ugettext_lazy as _ from model_utils import Choices @@ -6,7 +6,8 @@ from model_utils import Choices from sapl.comissoes.models import Comissao from sapl.parlamentares.models import Parlamentar, Partido from sapl.utils import (RANGE_ANOS, YES_NO_CHOICES, - restringe_tipos_de_arquivo_txt, xstr) + restringe_tipos_de_arquivo_txt, xstr, + get_settings_auth_user_model) def grupo_autor(): @@ -208,7 +209,8 @@ class TipoAutor(models.Model): class Autor(models.Model): - user = models.ForeignKey(User, blank=True, null=True) + user = models.ForeignKey( + get_settings_auth_user_model(), blank=True, null=True) partido = models.ForeignKey(Partido, blank=True, null=True) comissao = models.ForeignKey(Comissao, blank=True, null=True) parlamentar = models.ForeignKey(Parlamentar, blank=True, null=True) diff --git a/sapl/materia/tests/test_materia.py b/sapl/materia/tests/test_materia.py index d3a9573c9..953546c27 100644 --- a/sapl/materia/tests/test_materia.py +++ b/sapl/materia/tests/test_materia.py @@ -1,8 +1,8 @@ -import pytest -from django.contrib.auth.models import User +from django.contrib.auth import get_user_model from django.core.files.uploadedfile import SimpleUploadedFile from django.core.urlresolvers import reverse from model_mommy import mommy +import pytest from sapl.comissoes.models import Comissao, TipoComissao from sapl.materia.models import (Anexada, Autor, Autoria, DespachoInicial, @@ -434,7 +434,7 @@ def test_form_errors_relatoria(admin_client): @pytest.mark.django_db(transaction=False) def test_proposicao_submit(admin_client): tipo_autor = mommy.make(TipoAutor, descricao='Teste Tipo_Autor') - user = User.objects.filter(is_active=True)[0] + user = get_user_model().objects.filter(is_active=True)[0] autor = mommy.make( Autor, @@ -469,7 +469,7 @@ def test_proposicao_submit(admin_client): def test_form_errors_proposicao(admin_client): tipo_autor = mommy.make(TipoAutor, descricao='Teste Tipo_Autor') - user = User.objects.filter(is_active=True)[0] + user = get_user_model().objects.filter(is_active=True)[0] autor = mommy.make( Autor, @@ -484,7 +484,7 @@ def test_form_errors_proposicao(admin_client): {'autor': autor.pk, 'justificativa_devolucao': ' ', 'texto_original': texto, - 'salvar': 'salvar'}, + 'salvar': 'salvar'}, follow=True) assert (response.context_data['form'].errors['tipo'] == diff --git a/sapl/materia/views.py b/sapl/materia/views.py index ff1a849f4..4d0bcd5e2 100644 --- a/sapl/materia/views.py +++ b/sapl/materia/views.py @@ -6,8 +6,8 @@ from crispy_forms.helper import FormHelper from crispy_forms.layout import HTML, Button from django.conf import settings from django.contrib import messages +from django.contrib.auth import get_user_model from django.contrib.auth.mixins import PermissionRequiredMixin -from django.contrib.auth.models import User from django.contrib.auth.tokens import default_token_generator from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist from django.core.mail import send_mail @@ -54,6 +54,7 @@ from .models import (AcompanhamentoMateria, Anexada, Autor, Autoria, TipoFimRelatoria, TipoMateriaLegislativa, TipoProposicao, Tramitacao, UnidadeTramitacao) + AnexadaCrud = Crud.build(Anexada, '') @@ -62,6 +63,7 @@ class OrigemCrud(Crud): help_path = 'origem' class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): + def has_permission(self): return permissao_tb_aux(self) @@ -71,6 +73,7 @@ class TipoMateriaCrud(Crud): help_path = 'tipo_materia_legislativa' class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): + def has_permission(self): return permissao_tb_aux(self) @@ -80,6 +83,7 @@ class RegimeTramitacaoCrud(Crud): help_path = 'regime_tramitacao' class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): + def has_permission(self): return permissao_tb_aux(self) @@ -89,6 +93,7 @@ class TipoDocumentoCrud(Crud): help_path = 'tipo_documento' class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): + def has_permission(self): return permissao_tb_aux(self) @@ -98,6 +103,7 @@ class TipoFimRelatoriaCrud(Crud): help_path = 'fim_relatoria' class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): + def has_permission(self): return permissao_tb_aux(self) @@ -107,6 +113,7 @@ class TipoAutorCrud(Crud): help_path = 'tipo_autor' class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): + def has_permission(self): return permissao_tb_aux(self) @@ -130,7 +137,8 @@ class AutorCrud(Crud): pk_autor = Autor.objects.get( email=self.request.POST.get('email')).id kwargs = {} - user = User.objects.get(email=self.request.POST.get('email')) + user = get_user_model().objects.get( + email=self.request.POST.get('email')) kwargs['token'] = default_token_generator.make_token(user) kwargs['uidb64'] = urlsafe_base64_encode(force_bytes(user.pk)) assunto = "SAPL - Confirmação de Conta" @@ -159,7 +167,7 @@ class ConfirmarEmailView(TemplateView): def get(self, request, *args, **kwargs): uid = urlsafe_base64_decode(self.kwargs['uidb64']) - user = User.objects.get(id=uid) + user = get_user_model().objects.get(id=uid) user.is_active = True user.save() context = self.get_context_data(**kwargs) @@ -181,6 +189,7 @@ class TipoProposicaoCrud(Crud): help_path = 'tipo_proposicao' class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): + def has_permission(self): return permissao_tb_aux(self) @@ -453,7 +462,7 @@ class ProposicaoCrud(Crud): id=self.kwargs['pk'], autor__user_id=self.request.user.id) if (not proposicao.data_recebimento or - proposicao.data_devolucao): + proposicao.data_devolucao): return True else: msg = _('Essa proposição já foi recebida. ' + @@ -544,13 +553,13 @@ class ReciboProposicaoView(TemplateView): permission_required = permissoes_autor() def has_permission(self): - perms = self.get_permission_required() - if not self.request.user.has_perms(perms): - return False + perms = self.get_permission_required() + if not self.request.user.has_perms(perms): + return False - return (Proposicao.objects.filter( - id=self.kwargs['pk'], - autor__user_id=self.request.user.id).exists()) + return (Proposicao.objects.filter( + id=self.kwargs['pk'], + autor__user_id=self.request.user.id).exists()) def get_context_data(self, **kwargs): context = super(ReciboProposicaoView, self).get_context_data( diff --git a/sapl/parlamentares/views.py b/sapl/parlamentares/views.py index 089f93efd..d2d39c7fb 100644 --- a/sapl/parlamentares/views.py +++ b/sapl/parlamentares/views.py @@ -120,8 +120,8 @@ class ParticipacaoParlamentarCrud(MasterDetailCrud): if p.cargo.nome != 'Relator': comissao = [ (p.composicao.comissao.nome, reverse( - 'sapl.comissoes:comissao_detail', kwargs={ - 'pk': p.composicao.comissao.pk})), + 'sapl.comissoes:comissao_detail', kwargs={ + 'pk': p.composicao.comissao.pk})), (p.cargo.nome, None), (p.composicao.periodo.data_inicio.strftime( "%d/%m/%Y") + ' a ' + @@ -149,6 +149,7 @@ class CargoMesaCrud(Crud): help_path = 'cargo_mesa' class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): + def has_permission(self): return permissao_tb_aux(self) @@ -158,6 +159,7 @@ class PartidoCrud(Crud): help_path = 'partidos' class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): + def has_permission(self): return permissao_tb_aux(self) @@ -167,6 +169,7 @@ class SessaoLegislativaCrud(Crud): help_path = 'sessao_legislativa' class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): + def has_permission(self): return permissao_tb_aux(self) @@ -176,6 +179,7 @@ class TipoDependenteCrud(Crud): help_path = 'nivel_instrucao' class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): + def has_permission(self): return permissao_tb_aux(self) @@ -185,6 +189,7 @@ class NivelInstrucaoCrud(Crud): help_path = 'tipo_dependente' class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): + def has_permission(self): return permissao_tb_aux(self) @@ -194,6 +199,7 @@ class TipoAfastamentoCrud(Crud): help_path = 'tipo_afastamento' class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): + def has_permission(self): return permissao_tb_aux(self) @@ -203,6 +209,7 @@ class TipoMilitarCrud(Crud): help_path = 'tipo_situa_militar' class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): + def has_permission(self): return permissao_tb_aux(self) @@ -251,9 +258,10 @@ class ColigacaoCrud(Crud): help_path = 'tabelas_auxiliares#coligacao' class ListView(CrudListView): - ordering = ('-numero', 'nome') + ordering = ('-numero_votos', 'nome') class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): + def has_permission(self): return permissao_tb_aux(self) @@ -281,6 +289,7 @@ class ComposicaoColigacaoCrud(MasterDetailCrud): ordering = '-partido__sigla' class BaseMixin(PermissionRequiredMixin, MasterDetailCrud.BaseMixin): + def has_permission(self): return permissao_tb_aux(self) @@ -296,6 +305,7 @@ class LegislaturaCrud(Crud): form_class = LegislaturaForm class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): + def has_permission(self): return permissao_tb_aux(self) @@ -321,13 +331,13 @@ class FiliacaoCrud(MasterDetailCrud): def get_parlamentar_permissions(): - lista_permissoes = [] - cts = ContentType.objects.filter(app_label='parlamentares') - perms_parlamentares = list(Permission.objects.filter( - content_type__in=cts)) - for p in perms_parlamentares: - lista_permissoes.append('parlamentares.' + p.codename) - return set(lista_permissoes) + lista_permissoes = [] + cts = ContentType.objects.filter(app_label='parlamentares') + perms_parlamentares = list(Permission.objects.filter( + content_type__in=cts)) + for p in perms_parlamentares: + lista_permissoes.append('parlamentares.' + p.codename) + return set(lista_permissoes) class ParlamentarCrud(Crud): @@ -335,6 +345,7 @@ class ParlamentarCrud(Crud): help_path = '' class DetailView(CrudDetailView): + def get_template_names(self): usuario = self.request.user lista_permissoes = get_parlamentar_permissions() diff --git a/sapl/protocoloadm/forms.py b/sapl/protocoloadm/forms.py index 4d247adfa..c9e98e4fa 100644 --- a/sapl/protocoloadm/forms.py +++ b/sapl/protocoloadm/forms.py @@ -11,9 +11,9 @@ from django.forms import ModelForm from django.utils.translation import ugettext_lazy as _ from sapl.crispy_layout_mixin import form_actions, to_row -from sapl.materia.forms import RangeWidgetOverride from sapl.materia.models import Autor, UnidadeTramitacao -from sapl.utils import RANGE_ANOS, autor_label, autor_modal +from sapl.utils import (RANGE_ANOS, RangeWidgetOverride, autor_label, + autor_modal) from .models import (DocumentoAcessorioAdministrativo, DocumentoAdministrativo, Protocolo, TipoDocumentoAdministrativo, @@ -512,7 +512,7 @@ class TramitacaoAdmForm(ModelForm): raise ValidationError(msg) if (ultima_tramitacao and - data_tram_form < ultima_tramitacao.data_tramitacao): + data_tram_form < ultima_tramitacao.data_tramitacao): msg = _('A data da nova tramitação deve ser ' + 'maior que a data da última tramitação!') raise ValidationError(msg) diff --git a/sapl/sessao/views.py b/sapl/sessao/views.py index d31915f21..fdc1959ed 100644 --- a/sapl/sessao/views.py +++ b/sapl/sessao/views.py @@ -856,18 +856,14 @@ class ResumoView(SessaoCrud.CrudDetailView): # ===================================================================== # Expedientes expediente = ExpedienteSessao.objects.filter( - sessao_plenaria_id=self.object.id) + sessao_plenaria_id=self.object.id).order_by('tipo__nome') expedientes = [] for e in expediente: - tipo = TipoExpediente.objects.get( - id=e.tipo_id) - conteudo = sub( - ' ', ' ', strip_tags(e.conteudo)) - + tipo = TipoExpediente.objects.get(id=e.tipo_id) + conteudo = e.conteudo ex = {'tipo': tipo, 'conteudo': conteudo} expedientes.append(ex) - context.update({'expedientes': expedientes}) # ===================================================================== @@ -1001,16 +997,16 @@ class ExpedienteView(FormMixin, def get(self, request, *args, **kwargs): self.object = self.get_object() context = self.get_context_data(object=self.object) - - tipos = TipoExpediente.objects.all() + tipos = TipoExpediente.objects.all().order_by('nome') expedientes_sessao = ExpedienteSessao.objects.filter( - sessao_plenaria_id=self.object.id) + sessao_plenaria_id=self.object.id).order_by('tipo__nome') expedientes_salvos = [] for e in expedientes_sessao: expedientes_salvos.append(e.tipo) tipos_null = list(set(tipos) - set(expedientes_salvos)) + tipos_null.sort(key=lambda x: x.nome) expedientes = [] for e, t in zip(expedientes_sessao, tipos): diff --git a/sapl/static/styles/app.scss b/sapl/static/styles/app.scss index 27830c7e1..114d4052d 100644 --- a/sapl/static/styles/app.scss +++ b/sapl/static/styles/app.scss @@ -10,7 +10,9 @@ nav { &.navbar { + padding: 5px; border-radius: 0; + font-size: 15px; } } @@ -40,7 +42,6 @@ nav { .navbar-brand { padding: 0px; } - // ADJUST DRUNKEN PARROT STYLES ######################################## h1, .h1 { font-size: 30px; diff --git a/sapl/templates/sessao/resumo.html b/sapl/templates/sessao/resumo.html index bc1fe4b96..607064358 100644 --- a/sapl/templates/sessao/resumo.html +++ b/sapl/templates/sessao/resumo.html @@ -49,8 +49,10 @@ {% for e in expedientes %} - {{e.tipo}}:
- + {{e.tipo}}:

+
+

{{e.conteudo|safe}}

+
{% endfor %} @@ -61,22 +63,28 @@
Matérias do Expediente -
-
Matéria
-
Ementa
-
Resultado da Votação
-
-
- {% for m in materia_expediente %} -
- {{m.numero}} - {{m.titulo}} -
- Autor{{ m.autor|length|pluralize:"es" }}: {{ m.autor|join:', ' }} -
-
{{m.ementa|safe}}
-
{{m.resultado}}
- {% endfor %} -
+ + + + + + + + + + {% for m in materia_expediente %} + + + + + + {% endfor %} + +
MatériaEmentaResultado da Votação
+ {{m.numero}} - {{m.titulo}} +
+ Autor{{ m.autor|length|pluralize:"es" }}: {{ m.autor|join:', ' }} +
{{m.ementa|safe}}{{m.resultado}}



@@ -107,21 +115,27 @@
Matérias da Ordem do Dia -
-
Matéria
-
Ementa
-
Resultado da Votação
-
-
- {% for m in materias_ordem %} -
- {{m.numero}} - {{m.titulo}} -
- Autor{{ m.autor|length|pluralize:"es" }}: {{ m.autor|join:', ' }} -
-
{{m.ementa|safe}}
-
{{m.resultado}}
- {% endfor %} -
+ + + + + + + + + + {% for m in materias_ordem %} + + + + + + {% endfor %} + +
MatériaEmentaResultado da Votação
+ {{m.numero}} - {{m.titulo}} +
+ Autor{{ m.autor|length|pluralize:"es" }}: {{ m.autor|join:', ' }} +
{{m.ementa|safe}}{{m.resultado}}
{% endblock detail_content %} diff --git a/sapl/utils.py b/sapl/utils.py index b59b4f5b3..df4a895d1 100644 --- a/sapl/utils.py +++ b/sapl/utils.py @@ -3,6 +3,7 @@ from datetime import date from functools import wraps import magic +from django import forms from django.apps import apps from django.conf import settings from django.contrib import admin @@ -46,6 +47,28 @@ class ImageThumbnailFileInput(ClearableFileInput): template_name = 'floppyforms/image_thumbnail.html' +class RangeWidgetOverride(forms.MultiWidget): + + def __init__(self, attrs=None): + widgets = (forms.DateInput(format='%d/%m/%Y', + attrs={'class': 'dateinput', + 'placeholder': 'Inicial'}), + forms.DateInput(format='%d/%m/%Y', + attrs={'class': 'dateinput', + 'placeholder': 'Final'})) + super(RangeWidgetOverride, self).__init__(widgets, attrs) + + def decompress(self, value): + if value: + return [value.start, value.stop] + return [None, None] + + def format_output(self, rendered_widgets): + html = '
%s
%s
'\ + % tuple(rendered_widgets) + return '
%s
' % html + + def register_all_models_in_admin(module_name): appname = module_name.split('.') appname = appname[1] if appname[0] == 'sapl' else appname[0] diff --git a/scripts/inicializa_grupos_autorizacoes.py b/scripts/inicializa_grupos_autorizacoes.py index 378301910..1377d66e6 100644 --- a/scripts/inicializa_grupos_autorizacoes.py +++ b/scripts/inicializa_grupos_autorizacoes.py @@ -1,5 +1,6 @@ from django.apps import apps -from django.contrib.auth.models import Group, Permission, User +from django.contrib.auth import get_user_model +from django.contrib.auth.models import Group, Permission from django.contrib.contenttypes.models import ContentType @@ -12,7 +13,7 @@ def cria_ou_reseta_grupo(nome): def cria_usuario(nome, grupo): nome_usuario = nome - usuario = User.objects.get_or_create(username=nome_usuario)[0] + usuario = get_user_model().objects.get_or_create(username=nome_usuario)[0] usuario.set_password('interlegis') usuario.save() grupo.user_set.add(usuario) @@ -82,7 +83,8 @@ def cria_grupos_permissoes(): # Cria o Usuario nome_usuario = 'operador_%s' % nome_app - usuario = User.objects.get_or_create(username=nome_usuario)[0] + usuario = get_user_model().objects.get_or_create( + username=nome_usuario)[0] usuario.set_password('interlegis') usuario.save() grupo.user_set.add(usuario)