Extra validation of the uploaded ZIP #73
@ -4,7 +4,6 @@ import zipfile
|
||||
import tempfile
|
||||
|
||||
from django import forms
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
@ -140,7 +139,7 @@ class FileForm(forms.ModelForm):
|
||||
|
||||
errors = []
|
||||
if not zipfile.is_zipfile(file_path):
|
||||
errors.append(ValidationError(self.error_messages['invalid_zip_archive']))
|
||||
errors.append(forms.ValidationError(self.error_messages['invalid_zip_archive']))
|
||||
|
||||
manifest, error_codes = utils.read_manifest_from_zip(file_path)
|
||||
|
||||
@ -152,7 +151,7 @@ class FileForm(forms.ModelForm):
|
||||
self.cleaned_data['type'] = EXTENSION_SLUG_TYPES[manifest['type']]
|
||||
|
||||
for code in error_codes:
|
||||
errors.append(ValidationError(self.error_messages[code]))
|
||||
errors.append(forms.ValidationError(self.error_messages[code]))
|
||||
if errors:
|
||||
self.add_error('source', errors)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user