|
|
@ -193,6 +193,12 @@ class NormaJuridicaForm(FileFieldCheckMixin, ModelForm): |
|
|
else: |
|
|
else: |
|
|
cleaned_data['materia'] = None |
|
|
cleaned_data['materia'] = None |
|
|
|
|
|
|
|
|
|
|
|
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, (arquivo.size/1024)/1024)) |
|
|
|
|
|
|
|
|
return cleaned_data |
|
|
return cleaned_data |
|
|
|
|
|
|
|
|
def clean_texto_integral(self): |
|
|
def clean_texto_integral(self): |
|
|
@ -279,16 +285,16 @@ class AnexoNormaJuridicaForm(FileFieldCheckMixin, ModelForm): |
|
|
|
|
|
|
|
|
def clean(self): |
|
|
def clean(self): |
|
|
cleaned_data = super(AnexoNormaJuridicaForm, self).clean() |
|
|
cleaned_data = super(AnexoNormaJuridicaForm, self).clean() |
|
|
|
|
|
|
|
|
if not self.is_valid(): |
|
|
if not self.is_valid(): |
|
|
return cleaned_data |
|
|
return cleaned_data |
|
|
|
|
|
|
|
|
anexo_arquivo = self.cleaned_data.get('anexo_arquivo', False) |
|
|
anexo_arquivo = self.cleaned_data.get('anexo_arquivo', False) |
|
|
|
|
|
|
|
|
if anexo_arquivo and anexo_arquivo.size > MAX_DOC_UPLOAD_SIZE: |
|
|
if anexo_arquivo and anexo_arquivo.size > MAX_DOC_UPLOAD_SIZE: |
|
|
max_size = str(MAX_DOC_UPLOAD_SIZE / (1024 * 1024)) |
|
|
raise ValidationError("O Arquivo Anexo deve ser menor que {0:.1f} mb, o tamanho atual desse arquivo é {1:.1f} mb" \ |
|
|
tam_fornecido = str(anexo_arquivo.size / (1024 * 1024)) |
|
|
.format((MAX_DOC_UPLOAD_SIZE/1024)/1024, (arquivo.size/1024)/1024)) |
|
|
self.logger.error("Arquivo muito grande ({}MB). ( Tamanho máximo permitido: {}MB )".format( |
|
|
|
|
|
tam_fornecido, max_size)) |
|
|
|
|
|
raise ValidationError( |
|
|
|
|
|
"Arquivo muito grande. ( > {0}MB )".format(max_size)) |
|
|
|
|
|
return cleaned_data |
|
|
return cleaned_data |
|
|
|
|
|
|
|
|
def save(self, commit=False): |
|
|
def save(self, commit=False): |
|
|
|