|
|
@ -1,13 +1,11 @@ |
|
|
|
|
|
import django_filters |
|
|
import logging |
|
|
import logging |
|
|
|
|
|
|
|
|
from crispy_forms.bootstrap import InlineRadios, Alert, FormActions |
|
|
from crispy_forms.bootstrap import InlineRadios, Alert, FormActions |
|
|
|
|
|
from crispy_forms.layout import (Button, Column, Div, Fieldset, HTML, |
|
|
|
|
|
Layout, Submit) |
|
|
|
|
|
|
|
|
from sapl.base.signals import post_save_signal |
|
|
|
|
|
from sapl.crispy_layout_mixin import SaplFormHelper |
|
|
|
|
|
from crispy_forms.layout import HTML, Button, Column, Fieldset, Layout, Div, Submit |
|
|
|
|
|
from django import forms |
|
|
from django import forms |
|
|
from sapl.settings import MAX_DOC_UPLOAD_SIZE |
|
|
|
|
|
from django.core.exceptions import (MultipleObjectsReturned, |
|
|
from django.core.exceptions import (MultipleObjectsReturned, |
|
|
ObjectDoesNotExist, ValidationError) |
|
|
ObjectDoesNotExist, ValidationError) |
|
|
from django.db import models, transaction |
|
|
from django.db import models, transaction |
|
|
@ -15,24 +13,29 @@ from django.db.models import Max |
|
|
from django.forms import ModelForm |
|
|
from django.forms import ModelForm |
|
|
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 _ |
|
|
import django_filters |
|
|
|
|
|
|
|
|
|
|
|
from sapl.base.models import Autor, TipoAutor, AppConfig |
|
|
from sapl.base.models import Autor, TipoAutor, AppConfig |
|
|
from sapl.crispy_layout_mixin import SaplFormLayout, form_actions, to_row |
|
|
from sapl.base.signals import post_save_signal |
|
|
from sapl.materia.models import (MateriaLegislativa, TipoMateriaLegislativa, |
|
|
from sapl.crispy_layout_mixin import (form_actions, SaplFormHelper, |
|
|
|
|
|
SaplFormLayout, to_row) |
|
|
|
|
|
from sapl.materia.models import (MateriaLegislativa, |
|
|
|
|
|
TipoMateriaLegislativa, |
|
|
UnidadeTramitacao) |
|
|
UnidadeTramitacao) |
|
|
from sapl.protocoloadm.models import Protocolo |
|
|
from sapl.protocoloadm.models import Protocolo |
|
|
from sapl.utils import (RANGE_ANOS, YES_NO_CHOICES, AnoNumeroOrderingFilter, |
|
|
from sapl.settings import MAX_DOC_UPLOAD_SIZE |
|
|
RangeWidgetOverride, autor_label, autor_modal, |
|
|
from sapl.utils import (AnoNumeroOrderingFilter, autor_label, autor_modal, |
|
|
choice_anos_com_protocolo, choice_force_optional, |
|
|
|
|
|
choice_anos_com_documentoadministrativo, |
|
|
choice_anos_com_documentoadministrativo, |
|
|
FilterOverridesMetaMixin, choice_anos_com_materias, |
|
|
choice_anos_com_materias, |
|
|
FileFieldCheckMixin, lista_anexados) |
|
|
choice_anos_com_protocolo, choice_force_optional, |
|
|
|
|
|
FileFieldCheckMixin, FilterOverridesMetaMixin, |
|
|
|
|
|
lista_anexados, RangeWidgetOverride, RANGE_ANOS, |
|
|
|
|
|
validar_arquivo, YES_NO_CHOICES) |
|
|
|
|
|
|
|
|
from .models import (AcompanhamentoDocumento, DocumentoAcessorioAdministrativo, |
|
|
from .models import (Anexado, AcompanhamentoDocumento, |
|
|
DocumentoAdministrativo, |
|
|
DocumentoAcessorioAdministrativo, |
|
|
Protocolo, TipoDocumentoAdministrativo, |
|
|
DocumentoAdministrativo, Protocolo, |
|
|
TramitacaoAdministrativo, Anexado) |
|
|
TipoDocumentoAdministrativo, |
|
|
|
|
|
TramitacaoAdministrativo) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TIPOS_PROTOCOLO = [('0', 'Recebido'), ('1', 'Enviado'), |
|
|
TIPOS_PROTOCOLO = [('0', 'Recebido'), ('1', 'Enviado'), |
|
|
@ -667,16 +670,7 @@ class DocumentoAcessorioAdministrativoForm(FileFieldCheckMixin, ModelForm): |
|
|
arquivo = self.cleaned_data.get('arquivo', False) |
|
|
arquivo = self.cleaned_data.get('arquivo', False) |
|
|
|
|
|
|
|
|
if arquivo: |
|
|
if arquivo: |
|
|
if len(arquivo.name) > 200: |
|
|
validar_arquivo(arquivo, "Arquivo") |
|
|
raise ValidationError( |
|
|
|
|
|
"Certifique-se de que o nome do arquivo no campo 'Arquivo' tenha no máximo 200 " \ |
|
|
|
|
|
"caracteres (ele possui {})".format(len(arquivo.name)) |
|
|
|
|
|
) |
|
|
|
|
|
if arquivo.size > MAX_DOC_UPLOAD_SIZE: |
|
|
|
|
|
raise ValidationError( |
|
|
|
|
|
"O arquivo deve ser menor que {0:.1f} mb, o tamanho atual desse arquivo é {1:.1f} mb" \ |
|
|
|
|
|
.format((MAX_DOC_UPLOAD_SIZE/1024)/1024, (arquivo.size/1024)/1024) |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
return self.cleaned_data |
|
|
return self.cleaned_data |
|
|
|
|
|
|
|
|
@ -1168,19 +1162,7 @@ class DocumentoAdministrativoForm(FileFieldCheckMixin, ModelForm): |
|
|
texto_integral = self.cleaned_data.get('texto_integral', False) |
|
|
texto_integral = self.cleaned_data.get('texto_integral', False) |
|
|
|
|
|
|
|
|
if texto_integral: |
|
|
if texto_integral: |
|
|
if len(texto_integral.name) > 200: |
|
|
validar_arquivo(texto_integral, "Texto Integral") |
|
|
raise ValidationError( |
|
|
|
|
|
"Certifique-se de que o nome do arquivo no campo 'Texto Integral' tenha no máximo" \ |
|
|
|
|
|
" 200 caracteres (ele possui {})".format(len(texto_integral.name)) |
|
|
|
|
|
) |
|
|
|
|
|
if texto_integral.size > MAX_DOC_UPLOAD_SIZE: |
|
|
|
|
|
raise ValidationError( |
|
|
|
|
|
"O arquivo Texto Integral deve ser menor que {0:.1f} mb, o tamanho atual desse " \ |
|
|
|
|
|
"arquivo é {1:.1f} mb".format( |
|
|
|
|
|
(MAX_DOC_UPLOAD_SIZE/1024)/1024, |
|
|
|
|
|
(texto_integral.size/1024)/1024 |
|
|
|
|
|
) |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
return self.cleaned_data |
|
|
return self.cleaned_data |
|
|
|
|
|
|
|
|
|