diff options
author | Filipp Lepalaan <filipp@mac.com> | 2015-10-20 23:39:49 +0300 |
---|---|---|
committer | Filipp Lepalaan <filipp@mac.com> | 2015-10-20 23:39:49 +0300 |
commit | 07ef9e5daf68c864e34962bb63de938902b7c5d9 (patch) | |
tree | 906fd4ec864ca39a52bbbc7587f6b41ca04767b4 /servo | |
parent | 030b37348640af188879216074aea5809baa4908 (diff) | |
download | Servo-07ef9e5daf68c864e34962bb63de938902b7c5d9.tar.gz Servo-07ef9e5daf68c864e34962bb63de938902b7c5d9.tar.bz2 Servo-07ef9e5daf68c864e34962bb63de938902b7c5d9.zip |
Check for GSX max filesize
Diffstat (limited to 'servo')
-rw-r--r-- | servo/forms/repairs.py | 9 |
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) |