Browse Source

Merge

pull/626/head
Eduardo Calil 8 years ago
parent
commit
24f581e6e5
  1. 33
      sapl/base/forms.py
  2. 34
      sapl/materia/forms.py
  3. 8
      sapl/materia/models.py
  4. 10
      sapl/materia/tests/test_materia.py
  5. 29
      sapl/materia/views.py
  6. 31
      sapl/parlamentares/views.py
  7. 6
      sapl/protocoloadm/forms.py
  8. 16
      sapl/sessao/views.py
  9. 3
      sapl/static/styles/app.scss
  10. 82
      sapl/templates/sessao/resumo.html
  11. 23
      sapl/utils.py
  12. 8
      scripts/inicializa_grupos_autorizacoes.py

33
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',

34
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):

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

10
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'] ==

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

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

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

16
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(
'&nbsp;', ' ', 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):

3
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;

82
sapl/templates/sessao/resumo.html

@ -49,8 +49,10 @@
{% for e in expedientes %}
<tr>
<td>
<b>{{e.tipo}}: </b> <br />
<textarea name="ementa" class="textarea form-control" cols="40" rows="10" readonly="readonly">{{e.conteudo}}</textarea>
<b>{{e.tipo}}: </b> <br /><br />
<div contenteditable="false" style="border:0.5px solid #BAB4B1; border-radius: 10px; background-color: rgba(225, 225, 225, .8);">
<p>{{e.conteudo|safe}}</p>
</div>
</td>
</tr>
{% endfor %}
@ -61,22 +63,28 @@
<fieldset>
<legend>Matérias do Expediente</legend>
<div class="row">
<div class="col-md-4">Matéria</div>
<div class="col-md-4">Ementa</div>
<div class="col-md-4">Resultado da Votação</div>
</div>
<div class="row">
{% for m in materia_expediente %}
<div class="col-md-4">
{{m.numero}} - {{m.titulo}}
<br />
<b>Autor{{ m.autor|length|pluralize:"es" }}</b>: {{ m.autor|join:', ' }}
</div>
<div class="col-md-4">{{m.ementa|safe}}</div>
<div class="col-md-4">{{m.resultado}}</div>
{% endfor %}
</div>
<table class="table table-striped table-hover">
<thead>
<tr>
<th>Matéria</th>
<th>Ementa</th>
<th>Resultado da Votação</th>
</tr>
</thead>
<tbody>
{% for m in materia_expediente %}
<tr>
<td>
{{m.numero}} - {{m.titulo}}
<br />
<b>Autor{{ m.autor|length|pluralize:"es" }}</b>: {{ m.autor|join:', ' }}
</td>
<td>{{m.ementa|safe}}</td>
<td>{{m.resultado}}</td>
</tr>
{% endfor %}
</tbody>
</table>
</fieldset>
<br /><br /><br />
@ -107,21 +115,27 @@
<fieldset>
<legend>Matérias da Ordem do Dia</legend>
<div class="row">
<div class="col-md-4">Matéria</div>
<div class="col-md-4">Ementa</div>
<div class="col-md-4">Resultado da Votação</div>
</div>
<div class="row">
{% for m in materias_ordem %}
<div class="col-md-4">
{{m.numero}} - {{m.titulo}}
<br />
<b>Autor{{ m.autor|length|pluralize:"es" }}</b>: {{ m.autor|join:', ' }}
</div>
<div class="col-md-4">{{m.ementa|safe}}</div>
<div class="col-md-4">{{m.resultado}}</div>
{% endfor %}
</div>
<table class="table table-striped table-hover">
<thead>
<tr>
<th>Matéria</th>
<th>Ementa</th>
<th>Resultado da Votação</th>
</tr>
</thead>
<tbody>
{% for m in materias_ordem %}
<tr>
<td>
{{m.numero}} - {{m.titulo}}
<br />
<b>Autor{{ m.autor|length|pluralize:"es" }}</b>: {{ m.autor|join:', ' }}
</td>
<td>{{m.ementa|safe}}</td>
<td>{{m.resultado}}</td>
</tr>
{% endfor %}
</tbody>
</table>
</fieldset>
{% endblock detail_content %}

23
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 = '<div class="col-sm-6">%s</div><div class="col-sm-6">%s</div>'\
% tuple(rendered_widgets)
return '<div class="row">%s</div>' % html
def register_all_models_in_admin(module_name):
appname = module_name.split('.')
appname = appname[1] if appname[0] == 'sapl' else appname[0]

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

Loading…
Cancel
Save