Commit 47e92d08e06bcc0111db0536c109d19bbab8e1eb
1 parent
9daae87c
Exists in
master
and in
3 other branches
Fixing bugs in image validation
Showing
3 changed files
with
9 additions
and
5 deletions
Show diff stats
users/forms.py
... | ... | @@ -12,8 +12,9 @@ class Validation(forms.ModelForm): |
12 | 12 | image = self.cleaned_data.get('image', False) |
13 | 13 | |
14 | 14 | if image: |
15 | - if image._size > self.MAX_UPLOAD_SIZE: | |
16 | - raise forms.ValidationError(_("The image is too large. It should have less than 2MB.")) | |
15 | + if hasattr(image, '_size'): | |
16 | + if image._size > self.MAX_UPLOAD_SIZE: | |
17 | + raise forms.ValidationError(_("The image is too large. It should have less than 2MB.")) | |
17 | 18 | |
18 | 19 | return image |
19 | 20 | ... | ... |
users/models.py
... | ... | @@ -10,8 +10,9 @@ from django.contrib.staticfiles.templatetags.staticfiles import static |
10 | 10 | def validate_img_extension(value): |
11 | 11 | valid_formats = ['image/jpeg','image/x-citrix-jpeg','image/png','image/x-citrix-png','image/x-png'] |
12 | 12 | |
13 | - if not value.file.content_type in valid_formats: | |
14 | - raise ValidationError(_('File not supported.')) | |
13 | + if hasattr(value.file, 'content_type'): | |
14 | + if not value.file.content_type in valid_formats: | |
15 | + raise ValidationError(_('File not supported.')) | |
15 | 16 | |
16 | 17 | class User(AbstractBaseUser, PermissionsMixin): |
17 | 18 | ... | ... |
users/templates/users/profile.html
... | ... | @@ -54,10 +54,12 @@ |
54 | 54 | </div> |
55 | 55 | </div> |
56 | 56 | </div> |
57 | + <br clear="all" /> | |
58 | + <hr /> | |
57 | 59 | <div class="row-fluid"> |
58 | 60 | <label class="control-form">{% trans 'Description' %}:</label> |
59 | 61 | <div class="col-md-12"> |
60 | - {{ user.description|default:_("Not Informed")|linebreaks }} | |
62 | + {{ user.description|default:_("Not Informed") }} | |
61 | 63 | </div> |
62 | 64 | </div> |
63 | 65 | </div> | ... | ... |