Browse Source

Merge

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

25
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.materia.models import MateriaLegislativa
from sapl.sessao.models import SessaoPlenaria from sapl.sessao.models import SessaoPlenaria
from sapl.settings import MAX_IMAGE_UPLOAD_SIZE from sapl.settings import MAX_IMAGE_UPLOAD_SIZE
from sapl.utils import (RANGE_ANOS, ImageThumbnailFileInput, autor_label, from sapl.utils import (RANGE_ANOS, ImageThumbnailFileInput,
autor_modal) RangeWidgetOverride, autor_label, autor_modal)
from .models import AppConfig, CasaLegislativa 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): class RelatorioAtasFilterSet(django_filters.FilterSet):
filter_overrides = {models.DateField: { filter_overrides = {models.DateField: {
@ -287,6 +267,7 @@ class LoginForm(AuthenticationForm):
class ConfiguracoesAppForm(ModelForm): class ConfiguracoesAppForm(ModelForm):
class Meta: class Meta:
model = AppConfig model = AppConfig
fields = ['documentos_administrativos', fields = ['documentos_administrativos',

32
sapl/materia/forms.py

@ -1,9 +1,9 @@
from datetime import datetime from datetime import datetime
import django_filters
from crispy_forms.helper import FormHelper from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, Button, Column, Fieldset, Layout from crispy_forms.layout import HTML, Button, Column, Fieldset, Layout
from django import forms from django import forms
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group, User from django.contrib.auth.models import Group, User
from django.contrib.auth.password_validation import validate_password from django.contrib.auth.password_validation import validate_password
from django.core.exceptions import ObjectDoesNotExist, ValidationError 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.db.models import Max
from django.forms import ModelForm from django.forms import ModelForm
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
import django_filters
from sapl.comissoes.models import Comissao from sapl.comissoes.models import Comissao
from sapl.crispy_layout_mixin import form_actions, to_row from sapl.crispy_layout_mixin import form_actions, to_row
from sapl.norma.models import (LegislacaoCitada, NormaJuridica, from sapl.norma.models import (LegislacaoCitada, NormaJuridica,
TipoNormaJuridica) TipoNormaJuridica)
from sapl.settings import MAX_DOC_UPLOAD_SIZE 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, from .models import (AcompanhamentoMateria, Anexada, Autor, Autoria,
DespachoInicial, DocumentoAcessorio, MateriaLegislativa, DespachoInicial, DocumentoAcessorio, MateriaLegislativa,
Numeracao, Proposicao, Relatoria, TipoMateriaLegislativa, Numeracao, Proposicao, Relatoria, TipoMateriaLegislativa,
Tramitacao, UnidadeTramitacao) Tramitacao, UnidadeTramitacao)
ANO_CHOICES = [('', '---------')] + RANGE_ANOS ANO_CHOICES = [('', '---------')] + RANGE_ANOS
@ -34,6 +37,7 @@ def em_tramitacao():
class ConfirmarProposicaoForm(ModelForm): class ConfirmarProposicaoForm(ModelForm):
class Meta: class Meta:
model = Proposicao model = Proposicao
exclude = ['texto_original', 'descricao', 'tipo'] exclude = ['texto_original', 'descricao', 'tipo']
@ -445,26 +449,6 @@ class AnexadaForm(ModelForm):
fields = ['tipo', 'numero', 'ano', 'data_anexacao', 'data_desanexacao'] 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): class MateriaLegislativaFilterSet(django_filters.FilterSet):
filter_overrides = {models.DateField: { filter_overrides = {models.DateField: {
@ -688,11 +672,11 @@ class AutorForm(ModelForm):
return True return True
def valida_email_existente(self): def valida_email_existente(self):
return User.objects.filter( return get_user_model().objects.filter(
email=self.cleaned_data['email']).exists() email=self.cleaned_data['email']).exists()
def usuario_existente(self): def usuario_existente(self):
return User.objects.filter( return get_user_model().objects.filter(
username=self.cleaned_data['username']).exists() username=self.cleaned_data['username']).exists()
def clean(self): 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.db import models
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from model_utils import Choices from model_utils import Choices
@ -6,7 +6,8 @@ from model_utils import Choices
from sapl.comissoes.models import Comissao from sapl.comissoes.models import Comissao
from sapl.parlamentares.models import Parlamentar, Partido from sapl.parlamentares.models import Parlamentar, Partido
from sapl.utils import (RANGE_ANOS, YES_NO_CHOICES, 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(): def grupo_autor():
@ -208,7 +209,8 @@ class TipoAutor(models.Model):
class Autor(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) partido = models.ForeignKey(Partido, blank=True, null=True)
comissao = models.ForeignKey(Comissao, blank=True, null=True) comissao = models.ForeignKey(Comissao, blank=True, null=True)
parlamentar = models.ForeignKey(Parlamentar, blank=True, null=True) parlamentar = models.ForeignKey(Parlamentar, blank=True, null=True)

8
sapl/materia/tests/test_materia.py

@ -1,8 +1,8 @@
import pytest from django.contrib.auth import get_user_model
from django.contrib.auth.models import User
from django.core.files.uploadedfile import SimpleUploadedFile from django.core.files.uploadedfile import SimpleUploadedFile
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from model_mommy import mommy from model_mommy import mommy
import pytest
from sapl.comissoes.models import Comissao, TipoComissao from sapl.comissoes.models import Comissao, TipoComissao
from sapl.materia.models import (Anexada, Autor, Autoria, DespachoInicial, 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) @pytest.mark.django_db(transaction=False)
def test_proposicao_submit(admin_client): def test_proposicao_submit(admin_client):
tipo_autor = mommy.make(TipoAutor, descricao='Teste Tipo_Autor') 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 = mommy.make(
Autor, Autor,
@ -469,7 +469,7 @@ def test_proposicao_submit(admin_client):
def test_form_errors_proposicao(admin_client): def test_form_errors_proposicao(admin_client):
tipo_autor = mommy.make(TipoAutor, descricao='Teste Tipo_Autor') 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 = mommy.make(
Autor, Autor,

15
sapl/materia/views.py

@ -6,8 +6,8 @@ from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, Button from crispy_forms.layout import HTML, Button
from django.conf import settings from django.conf import settings
from django.contrib import messages from django.contrib import messages
from django.contrib.auth import get_user_model
from django.contrib.auth.mixins import PermissionRequiredMixin 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.contrib.auth.tokens import default_token_generator
from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist
from django.core.mail import send_mail from django.core.mail import send_mail
@ -54,6 +54,7 @@ from .models import (AcompanhamentoMateria, Anexada, Autor, Autoria,
TipoFimRelatoria, TipoMateriaLegislativa, TipoProposicao, TipoFimRelatoria, TipoMateriaLegislativa, TipoProposicao,
Tramitacao, UnidadeTramitacao) Tramitacao, UnidadeTramitacao)
AnexadaCrud = Crud.build(Anexada, '') AnexadaCrud = Crud.build(Anexada, '')
@ -62,6 +63,7 @@ class OrigemCrud(Crud):
help_path = 'origem' help_path = 'origem'
class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): class BaseMixin(PermissionRequiredMixin, CrudBaseMixin):
def has_permission(self): def has_permission(self):
return permissao_tb_aux(self) return permissao_tb_aux(self)
@ -71,6 +73,7 @@ class TipoMateriaCrud(Crud):
help_path = 'tipo_materia_legislativa' help_path = 'tipo_materia_legislativa'
class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): class BaseMixin(PermissionRequiredMixin, CrudBaseMixin):
def has_permission(self): def has_permission(self):
return permissao_tb_aux(self) return permissao_tb_aux(self)
@ -80,6 +83,7 @@ class RegimeTramitacaoCrud(Crud):
help_path = 'regime_tramitacao' help_path = 'regime_tramitacao'
class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): class BaseMixin(PermissionRequiredMixin, CrudBaseMixin):
def has_permission(self): def has_permission(self):
return permissao_tb_aux(self) return permissao_tb_aux(self)
@ -89,6 +93,7 @@ class TipoDocumentoCrud(Crud):
help_path = 'tipo_documento' help_path = 'tipo_documento'
class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): class BaseMixin(PermissionRequiredMixin, CrudBaseMixin):
def has_permission(self): def has_permission(self):
return permissao_tb_aux(self) return permissao_tb_aux(self)
@ -98,6 +103,7 @@ class TipoFimRelatoriaCrud(Crud):
help_path = 'fim_relatoria' help_path = 'fim_relatoria'
class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): class BaseMixin(PermissionRequiredMixin, CrudBaseMixin):
def has_permission(self): def has_permission(self):
return permissao_tb_aux(self) return permissao_tb_aux(self)
@ -107,6 +113,7 @@ class TipoAutorCrud(Crud):
help_path = 'tipo_autor' help_path = 'tipo_autor'
class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): class BaseMixin(PermissionRequiredMixin, CrudBaseMixin):
def has_permission(self): def has_permission(self):
return permissao_tb_aux(self) return permissao_tb_aux(self)
@ -130,7 +137,8 @@ class AutorCrud(Crud):
pk_autor = Autor.objects.get( pk_autor = Autor.objects.get(
email=self.request.POST.get('email')).id email=self.request.POST.get('email')).id
kwargs = {} 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['token'] = default_token_generator.make_token(user)
kwargs['uidb64'] = urlsafe_base64_encode(force_bytes(user.pk)) kwargs['uidb64'] = urlsafe_base64_encode(force_bytes(user.pk))
assunto = "SAPL - Confirmação de Conta" assunto = "SAPL - Confirmação de Conta"
@ -159,7 +167,7 @@ class ConfirmarEmailView(TemplateView):
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
uid = urlsafe_base64_decode(self.kwargs['uidb64']) 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.is_active = True
user.save() user.save()
context = self.get_context_data(**kwargs) context = self.get_context_data(**kwargs)
@ -181,6 +189,7 @@ class TipoProposicaoCrud(Crud):
help_path = 'tipo_proposicao' help_path = 'tipo_proposicao'
class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): class BaseMixin(PermissionRequiredMixin, CrudBaseMixin):
def has_permission(self): def has_permission(self):
return permissao_tb_aux(self) return permissao_tb_aux(self)

13
sapl/parlamentares/views.py

@ -149,6 +149,7 @@ class CargoMesaCrud(Crud):
help_path = 'cargo_mesa' help_path = 'cargo_mesa'
class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): class BaseMixin(PermissionRequiredMixin, CrudBaseMixin):
def has_permission(self): def has_permission(self):
return permissao_tb_aux(self) return permissao_tb_aux(self)
@ -158,6 +159,7 @@ class PartidoCrud(Crud):
help_path = 'partidos' help_path = 'partidos'
class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): class BaseMixin(PermissionRequiredMixin, CrudBaseMixin):
def has_permission(self): def has_permission(self):
return permissao_tb_aux(self) return permissao_tb_aux(self)
@ -167,6 +169,7 @@ class SessaoLegislativaCrud(Crud):
help_path = 'sessao_legislativa' help_path = 'sessao_legislativa'
class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): class BaseMixin(PermissionRequiredMixin, CrudBaseMixin):
def has_permission(self): def has_permission(self):
return permissao_tb_aux(self) return permissao_tb_aux(self)
@ -176,6 +179,7 @@ class TipoDependenteCrud(Crud):
help_path = 'nivel_instrucao' help_path = 'nivel_instrucao'
class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): class BaseMixin(PermissionRequiredMixin, CrudBaseMixin):
def has_permission(self): def has_permission(self):
return permissao_tb_aux(self) return permissao_tb_aux(self)
@ -185,6 +189,7 @@ class NivelInstrucaoCrud(Crud):
help_path = 'tipo_dependente' help_path = 'tipo_dependente'
class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): class BaseMixin(PermissionRequiredMixin, CrudBaseMixin):
def has_permission(self): def has_permission(self):
return permissao_tb_aux(self) return permissao_tb_aux(self)
@ -194,6 +199,7 @@ class TipoAfastamentoCrud(Crud):
help_path = 'tipo_afastamento' help_path = 'tipo_afastamento'
class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): class BaseMixin(PermissionRequiredMixin, CrudBaseMixin):
def has_permission(self): def has_permission(self):
return permissao_tb_aux(self) return permissao_tb_aux(self)
@ -203,6 +209,7 @@ class TipoMilitarCrud(Crud):
help_path = 'tipo_situa_militar' help_path = 'tipo_situa_militar'
class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): class BaseMixin(PermissionRequiredMixin, CrudBaseMixin):
def has_permission(self): def has_permission(self):
return permissao_tb_aux(self) return permissao_tb_aux(self)
@ -251,9 +258,10 @@ class ColigacaoCrud(Crud):
help_path = 'tabelas_auxiliares#coligacao' help_path = 'tabelas_auxiliares#coligacao'
class ListView(CrudListView): class ListView(CrudListView):
ordering = ('-numero', 'nome') ordering = ('-numero_votos', 'nome')
class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): class BaseMixin(PermissionRequiredMixin, CrudBaseMixin):
def has_permission(self): def has_permission(self):
return permissao_tb_aux(self) return permissao_tb_aux(self)
@ -281,6 +289,7 @@ class ComposicaoColigacaoCrud(MasterDetailCrud):
ordering = '-partido__sigla' ordering = '-partido__sigla'
class BaseMixin(PermissionRequiredMixin, MasterDetailCrud.BaseMixin): class BaseMixin(PermissionRequiredMixin, MasterDetailCrud.BaseMixin):
def has_permission(self): def has_permission(self):
return permissao_tb_aux(self) return permissao_tb_aux(self)
@ -296,6 +305,7 @@ class LegislaturaCrud(Crud):
form_class = LegislaturaForm form_class = LegislaturaForm
class BaseMixin(PermissionRequiredMixin, CrudBaseMixin): class BaseMixin(PermissionRequiredMixin, CrudBaseMixin):
def has_permission(self): def has_permission(self):
return permissao_tb_aux(self) return permissao_tb_aux(self)
@ -335,6 +345,7 @@ class ParlamentarCrud(Crud):
help_path = '' help_path = ''
class DetailView(CrudDetailView): class DetailView(CrudDetailView):
def get_template_names(self): def get_template_names(self):
usuario = self.request.user usuario = self.request.user
lista_permissoes = get_parlamentar_permissions() lista_permissoes = get_parlamentar_permissions()

4
sapl/protocoloadm/forms.py

@ -11,9 +11,9 @@ from django.forms import ModelForm
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from sapl.crispy_layout_mixin import form_actions, to_row 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.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, from .models import (DocumentoAcessorioAdministrativo, DocumentoAdministrativo,
Protocolo, TipoDocumentoAdministrativo, Protocolo, TipoDocumentoAdministrativo,

16
sapl/sessao/views.py

@ -856,18 +856,14 @@ class ResumoView(SessaoCrud.CrudDetailView):
# ===================================================================== # =====================================================================
# Expedientes # Expedientes
expediente = ExpedienteSessao.objects.filter( expediente = ExpedienteSessao.objects.filter(
sessao_plenaria_id=self.object.id) sessao_plenaria_id=self.object.id).order_by('tipo__nome')
expedientes = [] expedientes = []
for e in expediente: for e in expediente:
tipo = TipoExpediente.objects.get( tipo = TipoExpediente.objects.get(id=e.tipo_id)
id=e.tipo_id) conteudo = e.conteudo
conteudo = sub(
' ', ' ', strip_tags(e.conteudo))
ex = {'tipo': tipo, 'conteudo': conteudo} ex = {'tipo': tipo, 'conteudo': conteudo}
expedientes.append(ex) expedientes.append(ex)
context.update({'expedientes': expedientes}) context.update({'expedientes': expedientes})
# ===================================================================== # =====================================================================
@ -1001,16 +997,16 @@ class ExpedienteView(FormMixin,
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
self.object = self.get_object() self.object = self.get_object()
context = self.get_context_data(object=self.object) context = self.get_context_data(object=self.object)
tipos = TipoExpediente.objects.all().order_by('nome')
tipos = TipoExpediente.objects.all()
expedientes_sessao = ExpedienteSessao.objects.filter( expedientes_sessao = ExpedienteSessao.objects.filter(
sessao_plenaria_id=self.object.id) sessao_plenaria_id=self.object.id).order_by('tipo__nome')
expedientes_salvos = [] expedientes_salvos = []
for e in expedientes_sessao: for e in expedientes_sessao:
expedientes_salvos.append(e.tipo) expedientes_salvos.append(e.tipo)
tipos_null = list(set(tipos) - set(expedientes_salvos)) tipos_null = list(set(tipos) - set(expedientes_salvos))
tipos_null.sort(key=lambda x: x.nome)
expedientes = [] expedientes = []
for e, t in zip(expedientes_sessao, tipos): for e, t in zip(expedientes_sessao, tipos):

3
sapl/static/styles/app.scss

@ -10,7 +10,9 @@
nav { nav {
&.navbar { &.navbar {
padding: 5px;
border-radius: 0; border-radius: 0;
font-size: 15px;
} }
} }
@ -40,7 +42,6 @@ nav {
.navbar-brand { .navbar-brand {
padding: 0px; padding: 0px;
} }
// ADJUST DRUNKEN PARROT STYLES ######################################## // ADJUST DRUNKEN PARROT STYLES ########################################
h1, .h1 { h1, .h1 {
font-size: 30px; font-size: 30px;

62
sapl/templates/sessao/resumo.html

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

23
sapl/utils.py

@ -3,6 +3,7 @@ from datetime import date
from functools import wraps from functools import wraps
import magic import magic
from django import forms
from django.apps import apps from django.apps import apps
from django.conf import settings from django.conf import settings
from django.contrib import admin from django.contrib import admin
@ -46,6 +47,28 @@ class ImageThumbnailFileInput(ClearableFileInput):
template_name = 'floppyforms/image_thumbnail.html' 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): def register_all_models_in_admin(module_name):
appname = module_name.split('.') appname = module_name.split('.')
appname = appname[1] if appname[0] == 'sapl' else appname[0] 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.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 from django.contrib.contenttypes.models import ContentType
@ -12,7 +13,7 @@ def cria_ou_reseta_grupo(nome):
def cria_usuario(nome, grupo): def cria_usuario(nome, grupo):
nome_usuario = nome 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.set_password('interlegis')
usuario.save() usuario.save()
grupo.user_set.add(usuario) grupo.user_set.add(usuario)
@ -82,7 +83,8 @@ def cria_grupos_permissoes():
# Cria o Usuario # Cria o Usuario
nome_usuario = 'operador_%s' % nome_app 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.set_password('interlegis')
usuario.save() usuario.save()
grupo.user_set.add(usuario) grupo.user_set.add(usuario)

Loading…
Cancel
Save