diff --git a/protocoloadm/forms.py b/protocoloadm/forms.py index aec57b907..4942a0e71 100644 --- a/protocoloadm/forms.py +++ b/protocoloadm/forms.py @@ -1,11 +1,12 @@ from datetime import date -import sapl from crispy_forms.helper import FormHelper -from crispy_forms.layout import Fieldset, Layout, Submit +from crispy_forms.layout import HTML, Field, Fieldset, Layout, Submit from django import forms from django.forms import ModelForm from django.utils.safestring import mark_safe + +import sapl from materia.models import TipoMateriaLegislativa from sapl.layout import form_actions @@ -429,34 +430,6 @@ class TramitacaoAdmForm(ModelForm): class DocumentoAdministrativoForm(ModelForm): - data = forms.DateField(label=u'Data', - input_formats=['%d/%m/%Y'], - required=False, - widget=forms.DateInput( - format='%d/%m/%Y', - attrs={'class': 'dateinput'})) - - data_fim_prazo = forms.DateField(label=u'Data Fim Prazo', - input_formats=['%d/%m/%Y'], - required=False, - widget=forms.DateInput( - format='%d/%m/%Y', - attrs={'class': 'dateinput'})) - - tramitacao = forms.ChoiceField(required=True, - label='Em Tramitação?', - choices=tramitacao(), - widget=forms.Select( - attrs={'class': 'selector'})) - - assunto = forms.CharField( - label='Assunto', required=False, - widget=forms.Textarea()) - - observacao = forms.CharField( - label='Observação', required=False, - widget=forms.Textarea()) - class Meta: model = DocumentoAdministrativo fields = ['tipo', @@ -470,46 +443,39 @@ class DocumentoAdministrativoForm(ModelForm): 'dias_prazo', 'data_fim_prazo', 'observacao', - 'texto_integral' + 'texto_integral', ] def __init__(self, *args, **kwargs): row1 = sapl.layout.to_row( - [('tipo', 4), - ('numero', 4), - ('ano', 4)]) + [('tipo', 4), ('numero', 4), ('ano', 4)]) row2 = sapl.layout.to_row( - [('data', 6), - ('numero_protocolo', 6)]) + [('data', 6), ('numero_protocolo', 6)]) row3 = sapl.layout.to_row( [('assunto', 12)]) row4 = sapl.layout.to_row( - [('interessado', 9), - ('tramitacao', 3)]) + [('interessado', 9), ('tramitacao', 3)]) row5 = sapl.layout.to_row( [('texto_integral', 12)]) row6 = sapl.layout.to_row( - [('dias_prazo', 6), - ('data_fim_prazo', 6)]) + [('dias_prazo', 6), ('data_fim_prazo', 6)]) row7 = sapl.layout.to_row( [('observacao', 12)]) self.helper = FormHelper() self.helper.layout = Layout( - Fieldset('Formulário de Cadastro', - Fieldset('Identificação Básica', - row1, row2, row3, row4, row5), - Fieldset('Outras Informações', - row6, row7), - form_actions(more=[Submit('Excluir', 'Excluir')]), - ), + Fieldset('Identificação Básica', + row1, row2, row3, row4, row5), + Fieldset('Outras Informações', + row6, row7), + form_actions(more=[Submit('Excluir', 'Excluir')]), ) super(DocumentoAdministrativoForm, self).__init__( *args, **kwargs) diff --git a/protocoloadm/migrations/0007_auto_20160218_1429.py b/protocoloadm/migrations/0007_auto_20160218_1429.py new file mode 100644 index 000000000..51f753b83 --- /dev/null +++ b/protocoloadm/migrations/0007_auto_20160218_1429.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('protocoloadm', '0006_auto_20160216_1015'), + ] + + operations = [ + migrations.AlterField( + model_name='documentoadministrativo', + name='tramitacao', + field=models.BooleanField(choices=[(True, 'Sim'), (False, 'Não')], verbose_name='Em Tramitação?'), + ), + ] diff --git a/protocoloadm/models.py b/protocoloadm/models.py index 6dfe0733f..97408e787 100644 --- a/protocoloadm/models.py +++ b/protocoloadm/models.py @@ -2,7 +2,7 @@ from django.db import models from django.utils.translation import ugettext_lazy as _ from materia.models import Autor, TipoMateriaLegislativa, UnidadeTramitacao -from sapl.utils import make_choices +from sapl.utils import YES_NO_CHOICES, make_choices class TipoDocumentoAdministrativo(models.Model): @@ -40,7 +40,9 @@ class DocumentoAdministrativo(models.Model): blank=True, null=True, verbose_name=_('Dias Prazo')) data_fim_prazo = models.DateField( blank=True, null=True, verbose_name=_('Data Fim Prazo')) - tramitacao = models.BooleanField(verbose_name=_('Em Tramitação?')) + tramitacao = models.BooleanField( + verbose_name=_('Em Tramitação?'), + choices=YES_NO_CHOICES) assunto = models.TextField(verbose_name=_('Assunto')) observacao = models.TextField( blank=True, verbose_name=_('Observação')) diff --git a/protocoloadm/views.py b/protocoloadm/views.py index 5dda51f88..c848a6592 100644 --- a/protocoloadm/views.py +++ b/protocoloadm/views.py @@ -328,14 +328,12 @@ class CriarDocumentoProtocolo(FormMixin, GenericView): template_name = "protocoloadm/criar_documento.html" def get(self, request, *args, **kwargs): - numero = self.kwargs['pk'] ano = self.kwargs['ano'] protocolo = Protocolo.objects.get(ano=ano, numero=numero) form = DocumentoAdministrativoForm( initial=criar_documento(protocolo)) return self.render_to_response({ - 'protocolo': protocolo, 'form': form}) def post(self, request, *args, **kwargs):