Browse Source

Refatora form de pesquisa de protocolos

pull/2448/head
Leandro Roberto 6 years ago
parent
commit
c8e520509e
  1. 32
      sapl/protocoloadm/forms.py
  2. 26
      sapl/protocoloadm/migrations/0013_auto_20190106_1336.py
  3. 10
      sapl/protocoloadm/models.py

32
sapl/protocoloadm/forms.py

@ -29,12 +29,11 @@ from .models import (AcompanhamentoDocumento, DocumentoAcessorioAdministrativo,
TIPOS_PROTOCOLO = [('0', 'Recebido'), ('1', 'Enviado'), TIPOS_PROTOCOLO = [('0', 'Recebido'), ('1', 'Enviado'),
('2', 'Interno'), ('', '---------')] ('2', 'Interno')]
TIPOS_PROTOCOLO_CREATE = [ TIPOS_PROTOCOLO_CREATE = [
('0', 'Recebido'), ('1', 'Enviado'), ('2', 'Interno')] ('0', 'Recebido'), ('1', 'Enviado'), ('2', 'Interno')]
NATUREZA_PROCESSO = [('', '---------'), NATUREZA_PROCESSO = [('0', 'Administrativo'),
('0', 'Administrativo'),
('1', 'Legislativo')] ('1', 'Legislativo')]
@ -68,13 +67,18 @@ class AcompanhamentoDocumentoForm(ModelForm):
class ProtocoloFilterSet(django_filters.FilterSet): class ProtocoloFilterSet(django_filters.FilterSet):
ano = django_filters.ChoiceFilter(required=False, ano = django_filters.ChoiceFilter(
label='Ano', required=False,
choices=choice_anos_com_protocolo) label='Ano',
choices=choice_anos_com_protocolo)
assunto_ementa = django_filters.CharFilter(lookup_expr='icontains') assunto_ementa = django_filters.CharFilter(
label=_('Assunto'),
lookup_expr='icontains')
interessado = django_filters.CharFilter(lookup_expr='icontains') interessado = django_filters.CharFilter(
label=_('Interessado'),
lookup_expr='icontains')
autor = django_filters.CharFilter(widget=forms.HiddenInput()) autor = django_filters.CharFilter(widget=forms.HiddenInput())
@ -91,7 +95,7 @@ class ProtocoloFilterSet(django_filters.FilterSet):
widget=forms.Select( widget=forms.Select(
attrs={'class': 'selector'})) attrs={'class': 'selector'}))
o = AnoNumeroOrderingFilter() o = AnoNumeroOrderingFilter(help_text='')
class Meta: class Meta:
filter_overrides = {models.DateTimeField: { filter_overrides = {models.DateTimeField: {
@ -110,9 +114,6 @@ class ProtocoloFilterSet(django_filters.FilterSet):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(ProtocoloFilterSet, self).__init__(*args, **kwargs) super(ProtocoloFilterSet, self).__init__(*args, **kwargs)
self.filters['autor'].label = 'Tipo de Matéria'
self.filters['assunto_ementa'].label = 'Assunto'
row1 = to_row( row1 = to_row(
[('numero', 4), [('numero', 4),
('ano', 4), ('ano', 4),
@ -136,9 +137,7 @@ class ProtocoloFilterSet(django_filters.FilterSet):
'Limpar Autor', 'Limpar Autor',
css_class='btn btn-primary btn-sm'), 10)]) css_class='btn btn-primary btn-sm'), 10)])
row5 = to_row( row5 = to_row(
[('tipo_processo', 12)]) [('tipo_processo', 6), ('o', 6)])
row6 = to_row(
[('o', 12)])
self.form.helper = FormHelper() self.form.helper = FormHelper()
self.form.helper.form_method = 'GET' self.form.helper.form_method = 'GET'
@ -146,9 +145,10 @@ class ProtocoloFilterSet(django_filters.FilterSet):
Fieldset(_('Pesquisar Protocolo'), Fieldset(_('Pesquisar Protocolo'),
row1, row2, row1, row2,
row3, row3,
row5,
HTML(autor_label), HTML(autor_label),
HTML(autor_modal), HTML(autor_modal),
row4, row5, row6, row4,
form_actions(label='Pesquisar')) form_actions(label='Pesquisar'))
) )

26
sapl/protocoloadm/migrations/0013_auto_20190106_1336.py

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.8 on 2019-01-06 15:36
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('protocoloadm', '0012_auto_20190104_1021'),
]
operations = [
migrations.AlterField(
model_name='protocolo',
name='tipo_documento',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='protocoloadm.TipoDocumentoAdministrativo', verbose_name='Tipo de Documento'),
),
migrations.AlterField(
model_name='protocolo',
name='tipo_materia',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='materia.TipoMateriaLegislativa', verbose_name='Tipo de Matéria'),
),
]

10
sapl/protocoloadm/models.py

@ -1,8 +1,8 @@
import reversion
from django.db import models from django.db import models
from django.utils import timezone from django.utils import timezone
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
import reversion
from sapl.base.models import Autor from sapl.base.models import Autor
from sapl.materia.models import TipoMateriaLegislativa, UnidadeTramitacao from sapl.materia.models import TipoMateriaLegislativa, UnidadeTramitacao
@ -78,13 +78,13 @@ class Protocolo(models.Model):
blank=True, blank=True,
null=True, null=True,
on_delete=models.PROTECT, on_delete=models.PROTECT,
verbose_name=_('Tipo de documento')) verbose_name=_('Tipo de Documento'))
tipo_materia = models.ForeignKey( tipo_materia = models.ForeignKey(
TipoMateriaLegislativa, TipoMateriaLegislativa,
blank=True, blank=True,
null=True, null=True,
on_delete=models.PROTECT, on_delete=models.PROTECT,
verbose_name=_('Tipo Matéria')) verbose_name=_('Tipo de Matéria'))
numero_paginas = models.PositiveIntegerField( numero_paginas = models.PositiveIntegerField(
blank=True, null=True, verbose_name=_('Número de Páginas')) blank=True, null=True, verbose_name=_('Número de Páginas'))
observacao = models.TextField( observacao = models.TextField(
@ -299,10 +299,12 @@ class TramitacaoAdministrativo(models.Model):
'documento': self.documento, 'status': self.status 'documento': self.documento, 'status': self.status
} }
@reversion.register() @reversion.register()
class AcompanhamentoDocumento(models.Model): class AcompanhamentoDocumento(models.Model):
usuario = models.CharField(max_length=50) usuario = models.CharField(max_length=50)
documento = models.ForeignKey(DocumentoAdministrativo, on_delete=models.CASCADE) documento = models.ForeignKey(
DocumentoAdministrativo, on_delete=models.CASCADE)
email = models.EmailField( email = models.EmailField(
max_length=100, verbose_name=_('E-mail')) max_length=100, verbose_name=_('E-mail'))
data_cadastro = models.DateField(auto_now_add=True) data_cadastro = models.DateField(auto_now_add=True)

Loading…
Cancel
Save