diff options
author | Filipp Lepalaan <filipp@mac.com> | 2015-12-05 13:01:00 +0200 |
---|---|---|
committer | Filipp Lepalaan <filipp@mac.com> | 2015-12-05 13:01:00 +0200 |
commit | ea3518103895ad380d531502e32b03edf14cde47 (patch) | |
tree | 32debd00109726c887143e89cb854987f8613e43 /servo/forms | |
parent | 6d5964987eddfe9d4e3dbbcb0142420359259c35 (diff) | |
download | Servo-ea3518103895ad380d531502e32b03edf14cde47.tar.gz Servo-ea3518103895ad380d531502e32b03edf14cde47.tar.bz2 Servo-ea3518103895ad380d531502e32b03edf14cde47.zip |
Cleanup
Diffstat (limited to 'servo/forms')
-rw-r--r-- | servo/forms/account.py | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/servo/forms/account.py b/servo/forms/account.py index ac31720..d4704bb 100644 --- a/servo/forms/account.py +++ b/servo/forms/account.py @@ -29,22 +29,18 @@ class ProfileForm(BaseModelForm): 'queues': forms.CheckboxSelectMultiple } - password1 = forms.CharField( - widget=forms.PasswordInput, - required=False, - label=_("Password") - ) - password2 = forms.CharField( - widget=forms.PasswordInput, - required=False, - label=_("Confirmation") - ) + password1 = forms.CharField(widget=forms.PasswordInput, + required=False, + label=_("Password")) + password2 = forms.CharField(widget=forms.PasswordInput, + required=False, + label=_("Confirmation")) def clean(self): cd = super(ProfileForm, self).clean() if cd.get('gsx_password') == "": - del cd['gsx_password'] + del(cd['gsx_password']) cd['tech_id'] = cd['tech_id'].upper() @@ -55,9 +51,13 @@ class ProfileForm(BaseModelForm): return cd def clean_photo(self): + MAX_FILESIZE = 1*1024*1024 # 1 MB + from django.template.defaultfilters import filesizeformat photo = self.cleaned_data.get('photo') - if photo and photo.size > 1*1024*1024: - raise forms.ValidationError(_('File size of photo is too large')) + if photo and photo.size > MAX_FILESIZE: + size = filesizeformat(MAX_FILESIZE) + error = _('Profile picture should be no larger than %s') % size + raise forms.ValidationError(error) return photo |