Browse Source

hotfix: alt validator file para testar memory e temporary files

pull/3628/merge
LeandroJatai 2 years ago
committed by Edward Oliveira
parent
commit
77c9f7f0f3
  1. 10
      sapl/utils.py

10
sapl/utils.py

@ -22,7 +22,8 @@ from django.contrib.contenttypes.fields import (GenericForeignKey, GenericRel,
GenericRelation) GenericRelation)
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.core.files.storage import FileSystemStorage from django.core.files.storage import FileSystemStorage
from django.core.files.uploadedfile import UploadedFile from django.core.files.uploadedfile import UploadedFile, InMemoryUploadedFile,\
TemporaryUploadedFile
from django.core.mail import get_connection from django.core.mail import get_connection
from django.db import models from django.db import models
from django.db.models import Q from django.db.models import Q
@ -611,7 +612,12 @@ TIPOS_IMG_PERMITIDOS = (
def fabrica_validador_de_tipos_de_arquivo(lista, nome): def fabrica_validador_de_tipos_de_arquivo(lista, nome):
def restringe_tipos_de_arquivo(value): def restringe_tipos_de_arquivo(value):
if not os.path.splitext(value.path)[1][:1]:
filename = value.name if type(value) in (
InMemoryUploadedFile, TemporaryUploadedFile
) else value.path
if not os.path.splitext(filename)[1][:1]:
raise ValidationError(_( raise ValidationError(_(
'Não é possível fazer upload de arquivos sem extensão.')) 'Não é possível fazer upload de arquivos sem extensão.'))
try: try:

Loading…
Cancel
Save