From 24e4a82464741b299cd1f74fe4fea2a14c42d0ec Mon Sep 17 00:00:00 2001 From: Edward Ribeiro Date: Thu, 17 Mar 2016 09:08:21 -0300 Subject: [PATCH] =?UTF-8?q?Refatora=20tamanho=20m=C3=A1ximo=20de=20upload?= =?UTF-8?q?=20(doc,=20img)=20para=20vari=C3=A1vel=20'global'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- materia/forms.py | 5 +++-- norma/forms.py | 3 ++- parlamentares/forms.py | 3 ++- sapl/settings.py | 3 +++ sessao/forms.py | 5 +++-- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/materia/forms.py b/materia/forms.py index f9a4b4647..e2ccb7e19 100644 --- a/materia/forms.py +++ b/materia/forms.py @@ -9,6 +9,7 @@ import crispy_layout_mixin import sapl from crispy_layout_mixin import form_actions from norma.models import LegislacaoCitada, TipoNormaJuridica +from sapl.settings import MAX_DOC_UPLOAD_SIZE from .models import (AcompanhamentoMateria, Anexada, Autor, Autoria, DespachoInicial, DocumentoAcessorio, MateriaLegislativa, @@ -43,7 +44,7 @@ class ProposicaoForm(ModelForm): def clean_texto_original(self): texto_original = self.cleaned_data.get('texto_original', False) if texto_original: - if texto_original.size > 5*1024*1024: + if texto_original.size > MAX_DOC_UPLOAD_SIZE: raise ValidationError("Arquivo muito grande. ( > 5mb )") return texto_original @@ -409,7 +410,7 @@ class FormularioSimplificadoForm(ModelForm): def clean_texto_original(self): texto_original = self.cleaned_data.get('texto_original', False) if texto_original: - if texto_original.size > 5*1024*1024: + if texto_original.size > MAX_DOC_UPLOAD_SIZE: raise ValidationError("Arquivo muito grande. ( > 5mb )") return texto_original else: diff --git a/norma/forms.py b/norma/forms.py index 60f82f172..8b25e91a7 100644 --- a/norma/forms.py +++ b/norma/forms.py @@ -8,6 +8,7 @@ from django.utils.safestring import mark_safe import crispy_layout_mixin from crispy_layout_mixin import form_actions from materia.models import MateriaLegislativa, TipoMateriaLegislativa +from sapl.settings import MAX_DOC_UPLOAD_SIZE from sapl.utils import RANGE_ANOS from .models import NormaJuridica @@ -106,7 +107,7 @@ class NormaJuridicaForm(ModelForm): def clean_texto_integral(self): texto_integral = self.cleaned_data.get('texto_integral', False) if texto_integral: - if texto_integral.size > 5*1024*1024: + if texto_integral.size > MAX_DOC_UPLOAD_SIZE: raise ValidationError("Arquivo muito grande. ( > 5mb )") return texto_integral diff --git a/parlamentares/forms.py b/parlamentares/forms.py index 622f996ad..1ae31cef3 100644 --- a/parlamentares/forms.py +++ b/parlamentares/forms.py @@ -8,6 +8,7 @@ from django.utils.translation import ugettext_lazy as _ import crispy_layout_mixin from crispy_layout_mixin import form_actions +from sapl.settings import MAX_IMAGE_UPLOAD_SIZE from .models import Dependente, Filiacao, Legislatura, Mandato, Parlamentar @@ -34,7 +35,7 @@ class ParlamentaresForm (ModelForm): def clean_fotografia(self): fotografia = self.cleaned_data.get('fotografia', False) if fotografia: - if fotografia.size > 2*1024*1024: + if fotografia.size > MAX_IMAGE_UPLOAD_SIZE: raise ValidationError('Imagem muito grande. ( > 2mb )') return fotografia diff --git a/sapl/settings.py b/sapl/settings.py index 866354e43..996a0824f 100644 --- a/sapl/settings.py +++ b/sapl/settings.py @@ -121,6 +121,9 @@ EMAIL_HOST_USER = '' EMAIL_HOST_PASSWORD = '' EMAIL_PORT = 587 +MAX_DOC_UPLOAD_SIZE = 5*1024*1024 # 5MB +MAX_IMAGE_UPLOAD_SIZE = 2*1024*1024 # 2MB + # Internationalization # https://docs.djangoproject.com/en/1.8/topics/i18n/ LANGUAGE_CODE = 'pt-br' diff --git a/sessao/forms.py b/sessao/forms.py index 0f44294d9..a8b7fef88 100644 --- a/sessao/forms.py +++ b/sessao/forms.py @@ -7,6 +7,7 @@ from django.utils.translation import ugettext_lazy as _ import crispy_layout_mixin from crispy_layout_mixin import form_actions +from sapl.settings import MAX_DOC_UPLOAD_SIZE from .models import SessaoPlenaria @@ -96,14 +97,14 @@ class SessaoForm(ModelForm): def clean_url_audio(self): url_audio = self.cleaned_data.get('url_audio', False) if url_audio: - if url_audio.size > 5*1024*1024: + if url_audio.size > MAX_DOC_UPLOAD_SIZE: raise ValidationError("Arquivo muito grande. ( > 5mb )") return url_audio def clean_url_video(self): url_video = self.cleaned_data.get('url_video', False) if url_video: - if url_video.size > 5*1024*1024: + if url_video.size > MAX_DOC_UPLOAD_SIZE: raise ValidationError("Arquivo muito grande. ( > 5mb )") return url_video