From cd0e867e93d09ec40000bba22d71a4cb025beb7c Mon Sep 17 00:00:00 2001 From: Edward Ribeiro Date: Fri, 14 Jul 2017 18:18:29 -0300 Subject: [PATCH] Mostra valor real de limite de upload. --- sapl/materia/forms.py | 4 +++- sapl/norma/forms.py | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/sapl/materia/forms.py b/sapl/materia/forms.py index 123f8084c..47eabe43b 100644 --- a/sapl/materia/forms.py +++ b/sapl/materia/forms.py @@ -1022,7 +1022,9 @@ class ProposicaoForm(forms.ModelForm): texto_original = self.cleaned_data.get('texto_original', False) if texto_original: if texto_original.size > MAX_DOC_UPLOAD_SIZE: - raise ValidationError("Arquivo muito grande. ( > 5mb )") + max_size = str(MAX_DOC_UPLOAD_SIZE / (1024 * 1024)) + raise ValidationError( + "Arquivo muito grande. ( > {0}MB )".format(max_size)) return texto_original def clean(self): diff --git a/sapl/norma/forms.py b/sapl/norma/forms.py index ffdd09481..5ba72e161 100644 --- a/sapl/norma/forms.py +++ b/sapl/norma/forms.py @@ -144,7 +144,9 @@ class NormaJuridicaForm(ModelForm): texto_integral = self.cleaned_data.get('texto_integral', False) if texto_integral: if texto_integral.size > MAX_DOC_UPLOAD_SIZE: - raise ValidationError("Arquivo muito grande. ( > 5mb )") + max_size = str(MAX_DOC_UPLOAD_SIZE / (1024 * 1024)) + raise ValidationError( + "Arquivo muito grande. ( > {0}MB )".format(max_size)) return texto_integral def save(self, commit=False): @@ -178,7 +180,7 @@ class NormaRelacionadaForm(ModelForm): def clean(self): super(NormaRelacionadaForm, self).clean() - + if self.errors: return self.errors cleaned_data = self.cleaned_data