aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--servo/forms/repairs.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/servo/forms/repairs.py b/servo/forms/repairs.py
index 9348d1f..9f3a99d 100644
--- a/servo/forms/repairs.py
+++ b/servo/forms/repairs.py
@@ -94,4 +94,13 @@ class GsxRepairForm(forms.ModelForm):
if self.instance.has_serialized_parts():
if cd.get('mark_complete') and not cd.get('replacement_sn'):
raise forms.ValidationError(_('Replacement serial number must be set'))
+
return cd
+
+ def clean_attachment(self):
+ MAX_FILESIZE = 10485760 # 10MB
+ from django.template.defaultfilters import filesizeformat
+ f = self.cleaned_data['attachment']
+ if f and f._size > MAX_FILESIZE:
+ error = _('Attachment should be no larger than %s') % filesizeformat(MAX_FILESIZE)
+ raise forms.ValidationError(error)