mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2024-12-25 19:02:33 +00:00
Check that syntheses are valid files
This commit is contained in:
parent
d5e7295981
commit
3e0e6ae7b4
@ -119,7 +119,7 @@ class SolutionForm(forms.ModelForm):
|
|||||||
def clean_file(self):
|
def clean_file(self):
|
||||||
if "file" in self.files:
|
if "file" in self.files:
|
||||||
file = self.files["file"]
|
file = self.files["file"]
|
||||||
if file.size > 2e6:
|
if file.size > 5e6:
|
||||||
raise ValidationError(_("The uploaded file size must be under 5 Mo."))
|
raise ValidationError(_("The uploaded file size must be under 5 Mo."))
|
||||||
if file.content_type != "application/pdf":
|
if file.content_type != "application/pdf":
|
||||||
raise ValidationError(_("The uploaded file must be a PDF file."))
|
raise ValidationError(_("The uploaded file must be a PDF file."))
|
||||||
@ -179,6 +179,15 @@ class PassageForm(forms.ModelForm):
|
|||||||
|
|
||||||
|
|
||||||
class SynthesisForm(forms.ModelForm):
|
class SynthesisForm(forms.ModelForm):
|
||||||
|
def clean_file(self):
|
||||||
|
if "file" in self.files:
|
||||||
|
file = self.files["file"]
|
||||||
|
if file.size > 2e6:
|
||||||
|
raise ValidationError(_("The uploaded file size must be under 2 Mo."))
|
||||||
|
if file.content_type != "application/pdf":
|
||||||
|
raise ValidationError(_("The uploaded file must be a PDF file."))
|
||||||
|
return self.cleaned_data["photo_authorization"]
|
||||||
|
|
||||||
def save(self, commit=True):
|
def save(self, commit=True):
|
||||||
"""
|
"""
|
||||||
Don't save a synthesis with this way. Use a view instead
|
Don't save a synthesis with this way. Use a view instead
|
||||||
|
Loading…
Reference in New Issue
Block a user