Browse Source

Fix #3022 - Norma Jurídica

pull/3025/head
João Rodrigues 6 years ago
parent
commit
1a93dcd64c
  1. 15
      sapl/norma/forms.py
  2. 22
      sapl/norma/migrations/0028_auto_20191024_1330.py
  3. 2
      sapl/norma/models.py

15
sapl/norma/forms.py

@ -200,9 +200,18 @@ class NormaJuridicaForm(FileFieldCheckMixin, ModelForm):
texto_integral = self.cleaned_data.get('texto_integral', False) texto_integral = self.cleaned_data.get('texto_integral', False)
if texto_integral and texto_integral.size > MAX_DOC_UPLOAD_SIZE: if texto_integral:
raise ValidationError("O arquivo Texto Integral deve ser menor que {0:.1f} mb, o tamanho atual desse arquivo é {1:.1f} mb" \ if len(texto_integral.name) > 200:
.format((MAX_DOC_UPLOAD_SIZE/1024)/1024, (texto_integral.size/1024)/1024)) 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 texto_integral return texto_integral

22
sapl/norma/migrations/0028_auto_20191024_1330.py

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-10-24 16:30
from __future__ import unicode_literals
from django.db import migrations, models
import sapl.norma.models
import sapl.utils
class Migration(migrations.Migration):
dependencies = [
('norma', '0027_auto_20191001_1115'),
]
operations = [
migrations.AlterField(
model_name='normajuridica',
name='texto_integral',
field=models.FileField(blank=True, max_length=300, null=True, storage=sapl.utils.OverwriteStorage(), upload_to=sapl.norma.models.norma_upload_path, validators=[sapl.utils.restringe_tipos_de_arquivo_txt], verbose_name='Texto Integral'),
),
]

2
sapl/norma/models.py

@ -79,7 +79,7 @@ class NormaJuridica(models.Model):
) )
texto_integral = models.FileField( texto_integral = models.FileField(
max_length=200, max_length=300,
blank=True, blank=True,
null=True, null=True,
upload_to=norma_upload_path, upload_to=norma_upload_path,

Loading…
Cancel
Save