From 1a93dcd64c8732d7cccd3b85df4c5a273ae8edb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Rodrigues?= Date: Thu, 24 Oct 2019 13:34:31 -0300 Subject: [PATCH] =?UTF-8?q?Fix=20#3022=20-=20Norma=20Jur=C3=ADdica?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/norma/forms.py | 15 ++++++++++--- .../migrations/0028_auto_20191024_1330.py | 22 +++++++++++++++++++ sapl/norma/models.py | 2 +- 3 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 sapl/norma/migrations/0028_auto_20191024_1330.py diff --git a/sapl/norma/forms.py b/sapl/norma/forms.py index 6631d50dc..b3846b033 100644 --- a/sapl/norma/forms.py +++ b/sapl/norma/forms.py @@ -200,9 +200,18 @@ class NormaJuridicaForm(FileFieldCheckMixin, ModelForm): texto_integral = self.cleaned_data.get('texto_integral', False) - if texto_integral and 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)) + if texto_integral: + if len(texto_integral.name) > 200: + 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 diff --git a/sapl/norma/migrations/0028_auto_20191024_1330.py b/sapl/norma/migrations/0028_auto_20191024_1330.py new file mode 100644 index 000000000..22bd9e895 --- /dev/null +++ b/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'), + ), + ] diff --git a/sapl/norma/models.py b/sapl/norma/models.py index 05f0bbc5a..68ccc8482 100644 --- a/sapl/norma/models.py +++ b/sapl/norma/models.py @@ -79,7 +79,7 @@ class NormaJuridica(models.Model): ) texto_integral = models.FileField( - max_length=200, + max_length=300, blank=True, null=True, upload_to=norma_upload_path,