Extra validation of the uploaded ZIP #73

Merged
Anna Sirota merged 13 commits from validation-single-theme-xml into main 2024-04-11 12:32:50 +02:00
Showing only changes of commit 7db8fe1680 - Show all commits

View File

@ -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)