diff --git a/sapl/protocoloadm/forms.py b/sapl/protocoloadm/forms.py index a3b71e998..7fb1d2d7a 100644 --- a/sapl/protocoloadm/forms.py +++ b/sapl/protocoloadm/forms.py @@ -1,6 +1,5 @@ from datetime import datetime -import django_filters from crispy_forms.bootstrap import InlineRadios from crispy_forms.helper import FormHelper from crispy_forms.layout import HTML, Button, Fieldset, Layout, Submit @@ -9,8 +8,9 @@ from django.core.exceptions import ObjectDoesNotExist, ValidationError from django.db import models from django.forms import ModelForm from django.utils.translation import ugettext_lazy as _ +import django_filters -from sapl.base.models import Autor +from sapl.base.models import Autor, TipoAutor from sapl.crispy_layout_mixin import form_actions, to_row from sapl.materia.models import MateriaLegislativa, TipoMateriaLegislativa, UnidadeTramitacao from sapl.utils import (RANGE_ANOS, AnoNumeroOrderingFilter, @@ -20,6 +20,7 @@ from .models import (DocumentoAcessorioAdministrativo, DocumentoAdministrativo, Protocolo, TipoDocumentoAdministrativo, TramitacaoAdministrativo) + TIPOS_PROTOCOLO = [('0', 'Recebido'), ('1', 'Enviado'), ('', 'Ambos')] TIPOS_PROTOCOLO_CREATE = [('0', 'Recebido'), ('1', 'Enviado')] @@ -239,12 +240,13 @@ class AnularProcoloAdmForm(ModelForm): numero_protocolo=protocolo.numero, ano=protocolo.ano).exists() elif protocolo.tipo_documento: exists = protocolo.documentoadministrativo_set.all( - ).order_by('-ano', '-numero').exists() + ).order_by('-ano', '-numero').exists() if exists: raise forms.ValidationError( _("Protocolo %s/%s não pode ser removido pois existem" "documentos vinculados a ele." % (numero, ano))) + class Meta: model = Protocolo fields = ['numero', @@ -345,9 +347,14 @@ class ProtocoloDocumentForm(ModelForm): class ProtocoloMateriaForm(ModelForm): autor = forms.ModelChoiceField(required=True, - empty_label='------', - queryset=Autor.objects.all() - ) + empty_label='------', + queryset=Autor.objects.all() + ) + + tipo_autor = forms.ModelChoiceField(required=True, + empty_label='------', + queryset=TipoAutor.objects.all() + ) tipo_materia = forms.ModelChoiceField( label=_('Tipo de Matéria'), @@ -364,12 +371,12 @@ class ProtocoloMateriaForm(ModelForm): assunto_ementa = forms.CharField(required=True, widget=forms.Textarea, label='Ementa') - class Meta: model = Protocolo fields = ['tipo_materia', 'numero_paginas', 'autor', + 'tipo_autor', 'assunto_ementa', 'observacao'] @@ -387,9 +394,9 @@ class ProtocoloMateriaForm(ModelForm): row1 = to_row( [('tipo_materia', 4), - ('numero_paginas', 4)]) - row2 = to_row( - [('autor', 4)]) + ('numero_paginas', 2), + ('tipo_autor', 3), + ('autor', 3)]) row3 = to_row( [('assunto_ementa', 12)]) row4 = to_row( @@ -398,7 +405,7 @@ class ProtocoloMateriaForm(ModelForm): self.helper = FormHelper() self.helper.layout = Layout( Fieldset(_('Identificação da Matéria'), - row1, row2, row3, + row1, row3, row4, form_actions(save_label='Protocolar Matéria'))) super(ProtocoloMateriaForm, self).__init__( diff --git a/sapl/templates/protocoloadm/protocolar_materia.html b/sapl/templates/protocoloadm/protocolar_materia.html index 744126f0d..21d0db47e 100644 --- a/sapl/templates/protocoloadm/protocolar_materia.html +++ b/sapl/templates/protocoloadm/protocolar_materia.html @@ -13,3 +13,44 @@ {% block detail_content %} {% crispy form %} {% endblock detail_content %} + +{% block extra_js %} + +{% endblock %}