Private
Public Access
1
0
This commit is contained in:
Sander Roosendaal
2022-02-17 12:41:12 +01:00
parent 31109da378
commit e9c13d3fe7
3 changed files with 64 additions and 101 deletions

View File

@@ -4,7 +4,7 @@ import gzip
import shutil
import hashlib
from math import isinf, isnan
import uuid
@@ -60,7 +60,7 @@ def validate_image_extension(value):
ext = os.path.splitext(value.name)[1].lower()
valid_extension = ['.jpg', '.jpeg', '.png', '.gif']
if not ext in valid_extension: # pragma: no cover
if ext not in valid_extension: # pragma: no cover
raise ValidationError(u'File not supported')
@@ -71,7 +71,7 @@ def validate_file_extension(value):
'.CSV', '.fit', '.FIT', '.zip', '.ZIP',
'.gz', '.GZ', '.xls',
'.jpg', '.jpeg', '.tiff', '.png', '.gif', '.bmp']
if not ext in valid_extensions: # pragma: no cover
if ext not in valid_extensions: # pragma: no cover
raise ValidationError(u'File not supported!')
@@ -79,7 +79,7 @@ def must_be_csv(value):
import os
ext = os.path.splitext(value.name)[1]
valid_extensions = ['.csv', '.CSV']
if not ext in valid_extensions: # pragma: no cover
if ext not in valid_extensions: # pragma: no cover
raise ValidationError(u'File not supported!')
@@ -87,7 +87,7 @@ def validate_kml(value):
import os
ext = os.path.splitext(value.name)[1]
valid_extensions = ['.kml', '.KML']
if not ext in valid_extensions: # pragma: no cover
if ext not in valid_extensions: # pragma: no cover
raise ValidationError(u'File not supported!')
@@ -144,8 +144,6 @@ def handle_uploaded_file(f):
fname = f.name
ext = fname.split('.')[-1]
fname = '%s.%s' % (uuid.uuid4(), ext)
#timestr = uuid.uuid4().hex[:10]+'-'+time.strftime("%Y%m%d-%H%M%S")
#fname = timestr+'-'+fname
fname2 = 'media/'+fname
with open(fname2, 'wb+') as destination:
for chunk in f.chunks():