Commit 50c09a62cb14169a240a1af708dae83e0c1ea519

Authored by fbormann
2 parents 495dbd8a 6f3a606b

Merge branch 'refactoring' of https://github.com/amadeusproject/amadeuslms into refactoring

@@ -51,5 +51,6 @@ coverage.xml @@ -51,5 +51,6 @@ coverage.xml
51 angular_api 51 angular_api
52 logs/ 52 logs/
53 amadeus/uploads/ 53 amadeus/uploads/
  54 +data/
54 links/static/images/ 55 links/static/images/
55 uploads/ 56 uploads/
amadeus/settings.py
@@ -56,6 +56,7 @@ INSTALLED_APPS = [ @@ -56,6 +56,7 @@ INSTALLED_APPS = [
56 'django_crontab', 56 'django_crontab',
57 'django_cron', 57 'django_cron',
58 'channels', 58 'channels',
  59 + 'resubmit', # Utilizado para salvar arquivos na cache, para caso o formulario não seja preenchido corretamente o usuário não precise fazer o upload outra vez dos arquivos
59 60
60 'amadeus', 61 'amadeus',
61 'users', 62 'users',
@@ -120,6 +121,17 @@ TEMPLATES = [ @@ -120,6 +121,17 @@ TEMPLATES = [
120 }, 121 },
121 ] 122 ]
122 123
  124 +
  125 +CACHES = {
  126 + 'default': {
  127 + 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
  128 + },
  129 + "resubmit": {
  130 + 'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
  131 + "LOCATION": os.path.join(BASE_DIR, 'data/cache/resubmit'),
  132 + },
  133 +}
  134 +
123 WSGI_APPLICATION = 'amadeus.wsgi.application' 135 WSGI_APPLICATION = 'amadeus.wsgi.application'
124 136
125 SESSION_SECURITY_WARN_AFTER = 1140 137 SESSION_SECURITY_WARN_AFTER = 1140
@@ -357,11 +369,11 @@ SUMMERNOTE_CONFIG = { @@ -357,11 +369,11 @@ SUMMERNOTE_CONFIG = {
357 # Set `upload_to` function for attachments. 369 # Set `upload_to` function for attachments.
358 #'attachment_upload_to': my_custom_upload_to_func(), 370 #'attachment_upload_to': my_custom_upload_to_func(),
359 371
360 - 372 +
361 373
362 } 374 }
363 375
364 try: 376 try:
365 from .local_settings import * 377 from .local_settings import *
366 except ImportError: 378 except ImportError:
367 - pass  
368 \ No newline at end of file 379 \ No newline at end of file
  380 + pass
mural/forms.py
@@ -4,6 +4,8 @@ from django.utils.translation import ugettext_lazy as _ @@ -4,6 +4,8 @@ from django.utils.translation import ugettext_lazy as _
4 from django.utils.html import strip_tags 4 from django.utils.html import strip_tags
5 from django.db.models import Q 5 from django.db.models import Q
6 6
  7 +from resubmit.widgets import ResubmitFileWidget
  8 +
7 from topics.models import Resource 9 from topics.models import Resource
8 10
9 from .models import GeneralPost, CategoryPost, SubjectPost, Comment 11 from .models import GeneralPost, CategoryPost, SubjectPost, Comment
@@ -14,7 +16,7 @@ class Validation(forms.ModelForm): @@ -14,7 +16,7 @@ class Validation(forms.ModelForm):
14 def clean_post(self): 16 def clean_post(self):
15 post = self.cleaned_data.get('post', '') 17 post = self.cleaned_data.get('post', '')
16 cleaned_post = strip_tags(post) 18 cleaned_post = strip_tags(post)
17 - 19 +
18 if cleaned_post == '': 20 if cleaned_post == '':
19 self._errors['post'] = [_('This field is required.')] 21 self._errors['post'] = [_('This field is required.')]
20 22
@@ -34,13 +36,15 @@ class Validation(forms.ModelForm): @@ -34,13 +36,15 @@ class Validation(forms.ModelForm):
34 36
35 return image 37 return image
36 38
  39 +
37 class GeneralPostForm(Validation): 40 class GeneralPostForm(Validation):
38 class Meta: 41 class Meta:
39 model = GeneralPost 42 model = GeneralPost
40 fields = ['action', 'post', 'image'] 43 fields = ['action', 'post', 'image']
41 widgets = { 44 widgets = {
42 'action': forms.RadioSelect, 45 'action': forms.RadioSelect,
43 - 'post': forms.Textarea 46 + 'post': forms.Textarea,
  47 + 'image': ResubmitFileWidget(attrs={'accept':'image/*'}),
44 } 48 }
45 49
46 class CategoryPostForm(Validation): 50 class CategoryPostForm(Validation):
@@ -49,7 +53,8 @@ class CategoryPostForm(Validation): @@ -49,7 +53,8 @@ class CategoryPostForm(Validation):
49 fields = ['action', 'post', 'image'] 53 fields = ['action', 'post', 'image']
50 widgets = { 54 widgets = {
51 'action': forms.RadioSelect, 55 'action': forms.RadioSelect,
52 - 'post': forms.Textarea 56 + 'post': forms.Textarea,
  57 + 'image': ResubmitFileWidget(attrs={'accept':'image/*'}),
53 } 58 }
54 59
55 class SubjectPostForm(Validation): 60 class SubjectPostForm(Validation):
@@ -60,7 +65,7 @@ class SubjectPostForm(Validation): @@ -60,7 +65,7 @@ class SubjectPostForm(Validation):
60 subject = kwargs['initial'].get('subject', None) 65 subject = kwargs['initial'].get('subject', None)
61 66
62 if not kwargs['instance'] is None: 67 if not kwargs['instance'] is None:
63 - subject = self.instance.space 68 + subject = self.instance.space
64 69
65 if user.is_staff: 70 if user.is_staff:
66 self.fields['resource'].choices = [(r.id, str(r)) for r in Resource.objects.filter(Q(topic__subject = subject))] 71 self.fields['resource'].choices = [(r.id, str(r)) for r in Resource.objects.filter(Q(topic__subject = subject))]
@@ -74,7 +79,8 @@ class SubjectPostForm(Validation): @@ -74,7 +79,8 @@ class SubjectPostForm(Validation):
74 fields = ['action', 'resource', 'post', 'image'] 79 fields = ['action', 'resource', 'post', 'image']
75 widgets = { 80 widgets = {
76 'action': forms.RadioSelect, 81 'action': forms.RadioSelect,
77 - 'post': forms.Textarea 82 + 'post': forms.Textarea,
  83 + 'image': ResubmitFileWidget(attrs={'accept':'image/*'}),
78 } 84 }
79 85
80 class ResourcePostForm(Validation): 86 class ResourcePostForm(Validation):
@@ -83,7 +89,8 @@ class ResourcePostForm(Validation): @@ -83,7 +89,8 @@ class ResourcePostForm(Validation):
83 fields = ['action', 'post', 'image'] 89 fields = ['action', 'post', 'image']
84 widgets = { 90 widgets = {
85 'action': forms.RadioSelect, 91 'action': forms.RadioSelect,
86 - 'post': forms.Textarea 92 + 'post': forms.Textarea,
  93 + 'image': ResubmitFileWidget(attrs={'accept':'image/*'}),
87 } 94 }
88 95
89 class CommentForm(forms.ModelForm): 96 class CommentForm(forms.ModelForm):
@@ -92,7 +99,7 @@ class CommentForm(forms.ModelForm): @@ -92,7 +99,7 @@ class CommentForm(forms.ModelForm):
92 def clean_comment(self): 99 def clean_comment(self):
93 comment = self.cleaned_data.get('comment', '') 100 comment = self.cleaned_data.get('comment', '')
94 cleaned_comment = strip_tags(comment) 101 cleaned_comment = strip_tags(comment)
95 - 102 +
96 if cleaned_comment == '': 103 if cleaned_comment == '':
97 self._errors['comment'] = [_('This field is required.')] 104 self._errors['comment'] = [_('This field is required.')]
98 105
@@ -114,4 +121,7 @@ class CommentForm(forms.ModelForm): @@ -114,4 +121,7 @@ class CommentForm(forms.ModelForm):
114 121
115 class Meta: 122 class Meta:
116 model = Comment 123 model = Comment
117 - fields = ['comment', 'image']  
118 \ No newline at end of file 124 \ No newline at end of file
  125 + fields = ['comment', 'image']
  126 + widgets = {
  127 + 'image': ResubmitFileWidget(attrs={'accept':'image/*'}),
  128 + }
mural/templates/mural/_form.html
@@ -33,7 +33,7 @@ @@ -33,7 +33,7 @@
33 {% render_field form.resource class='form-control' %} 33 {% render_field form.resource class='form-control' %}
34 34
35 <span id="helpBlock" class="help-block">{{ form.resource.help_text }}</span> 35 <span id="helpBlock" class="help-block">{{ form.resource.help_text }}</span>
36 - 36 +
37 {% if form.resource.errors %} 37 {% if form.resource.errors %}
38 <div class="alert alert-danger alert-dismissible" role="alert"> 38 <div class="alert alert-danger alert-dismissible" role="alert">
39 <button type="button" class="close" data-dismiss="alert" aria-label="Close"> 39 <button type="button" class="close" data-dismiss="alert" aria-label="Close">
@@ -54,7 +54,7 @@ @@ -54,7 +54,7 @@
54 {% render_field form.post class='form-control text_simple_wysiwyg' %} 54 {% render_field form.post class='form-control text_simple_wysiwyg' %}
55 55
56 <span id="helpBlock" class="help-block">{{ form.post.help_text }}</span> 56 <span id="helpBlock" class="help-block">{{ form.post.help_text }}</span>
57 - 57 +
58 {% if form.post.errors %} 58 {% if form.post.errors %}
59 <div class="alert alert-danger alert-dismissible" role="alert"> 59 <div class="alert alert-danger alert-dismissible" role="alert">
60 <button type="button" class="close" data-dismiss="alert" aria-label="Close"> 60 <button type="button" class="close" data-dismiss="alert" aria-label="Close">
@@ -71,24 +71,15 @@ @@ -71,24 +71,15 @@
71 71
72 <div class="form-group{% if form.has_error %} has-error {% endif %} is-fileinput"> 72 <div class="form-group{% if form.has_error %} has-error {% endif %} is-fileinput">
73 {% render_field form.image %} 73 {% render_field form.image %}
74 -  
75 - <div class="input-group common-file-input">  
76 - <input type="text" readonly="" class="form-control" placeholder="{% trans 'Choose your photo...' %}">  
77 - <span class="input-group-btn input-group-sm">  
78 - <button type="button" class="btn btn-fab btn-fab-mini">  
79 - <i class="material-icons">attach_file</i>  
80 - </button>  
81 - </span>  
82 - </div>  
83 74
84 <div class="filedrag"> 75 <div class="filedrag">
85 {% trans 'Click or drop the file here' %}<br /> 76 {% trans 'Click or drop the file here' %}<br />
86 - 77 +
87 <small>{% trans 'The file could not exceed 5MB.' %}</small> 78 <small>{% trans 'The file could not exceed 5MB.' %}</small>
88 </div> 79 </div>
89 80
90 <span id="helpBlock" class="help-block">{{ form.image.help_text }}</span> 81 <span id="helpBlock" class="help-block">{{ form.image.help_text }}</span>
91 - 82 +
92 {% if form.image.errors %} 83 {% if form.image.errors %}
93 <div class="alert alert-danger alert-dismissible" role="alert"> 84 <div class="alert alert-danger alert-dismissible" role="alert">
94 <button type="button" class="close" data-dismiss="alert" aria-label="Close"> 85 <button type="button" class="close" data-dismiss="alert" aria-label="Close">
@@ -137,7 +128,7 @@ @@ -137,7 +128,7 @@
137 var small = $("#id_image"), 128 var small = $("#id_image"),
138 filedrag = $(".filedrag"), 129 filedrag = $(".filedrag"),
139 common = $(".common-file-input"); 130 common = $(".common-file-input");
140 - 131 +
141 // file select 132 // file select
142 small.on("change", FileSelectHandler); 133 small.on("change", FileSelectHandler);
143 134
pdf_file/forms.py
@@ -3,6 +3,7 @@ from django.utils.translation import ugettext_lazy as _ @@ -3,6 +3,7 @@ from django.utils.translation import ugettext_lazy as _
3 from django.utils.html import strip_tags 3 from django.utils.html import strip_tags
4 4
5 from subjects.models import Tag 5 from subjects.models import Tag
  6 +from resubmit.widgets import ResubmitFileWidget
6 7
7 from .models import PDFFile 8 from .models import PDFFile
8 9
@@ -17,7 +18,7 @@ class PDFFileForm(forms.ModelForm): @@ -17,7 +18,7 @@ class PDFFileForm(forms.ModelForm):
17 if self.instance.id: 18 if self.instance.id:
18 self.subject = self.instance.topic.subject 19 self.subject = self.instance.topic.subject
19 self.initial['tags'] = ", ".join(self.instance.tags.all().values_list("name", flat = True)) 20 self.initial['tags'] = ", ".join(self.instance.tags.all().values_list("name", flat = True))
20 - 21 +
21 self.fields['students'].queryset = self.subject.students.all() 22 self.fields['students'].queryset = self.subject.students.all()
22 self.fields['groups'].queryset = self.subject.group_subject.all() 23 self.fields['groups'].queryset = self.subject.group_subject.all()
23 24
@@ -32,11 +33,12 @@ class PDFFileForm(forms.ModelForm): @@ -32,11 +33,12 @@ class PDFFileForm(forms.ModelForm):
32 'brief_description': forms.Textarea, 33 'brief_description': forms.Textarea,
33 'students': forms.SelectMultiple, 34 'students': forms.SelectMultiple,
34 'groups': forms.SelectMultiple, 35 'groups': forms.SelectMultiple,
  36 + 'file': ResubmitFileWidget(attrs={'accept':'application/pdf, application/x-pdf, application/x-bzpdf, application/x-gzpdf'}),
35 } 37 }
36 38
37 def clean_name(self): 39 def clean_name(self):
38 name = self.cleaned_data.get('name', '') 40 name = self.cleaned_data.get('name', '')
39 - 41 +
40 topics = self.subject.topic_subject.all() 42 topics = self.subject.topic_subject.all()
41 43
42 for topic in topics: 44 for topic in topics:
@@ -44,7 +46,7 @@ class PDFFileForm(forms.ModelForm): @@ -44,7 +46,7 @@ class PDFFileForm(forms.ModelForm):
44 same_name = topic.resource_topic.filter(name__unaccent__iexact = name).exclude(id = self.instance.id).count() 46 same_name = topic.resource_topic.filter(name__unaccent__iexact = name).exclude(id = self.instance.id).count()
45 else: 47 else:
46 same_name = topic.resource_topic.filter(name__unaccent__iexact = name).count() 48 same_name = topic.resource_topic.filter(name__unaccent__iexact = name).count()
47 - 49 +
48 if same_name > 0: 50 if same_name > 0:
49 self._errors['name'] = [_('This subject already has a pdf file with this name')] 51 self._errors['name'] = [_('This subject already has a pdf file with this name')]
50 52
@@ -54,14 +56,14 @@ class PDFFileForm(forms.ModelForm): @@ -54,14 +56,14 @@ class PDFFileForm(forms.ModelForm):
54 56
55 def clean_file(self): 57 def clean_file(self):
56 file = self.cleaned_data.get('file', False) 58 file = self.cleaned_data.get('file', False)
57 - 59 +
58 if file: 60 if file:
59 if hasattr(file, '_size'): 61 if hasattr(file, '_size'):
60 if file._size > self.MAX_UPLOAD_SIZE: 62 if file._size > self.MAX_UPLOAD_SIZE:
61 self._errors['file'] = [_("The file is too large. It should have less than 10MB.")] 63 self._errors['file'] = [_("The file is too large. It should have less than 10MB.")]
62 64
63 return ValueError 65 return ValueError
64 - 66 +
65 elif not self.instance.pk: 67 elif not self.instance.pk:
66 self._errors['file'] = [_('This field is required.')] 68 self._errors['file'] = [_('This field is required.')]
67 69
@@ -82,7 +84,7 @@ class PDFFileForm(forms.ModelForm): @@ -82,7 +84,7 @@ class PDFFileForm(forms.ModelForm):
82 for prev in previous_tags: 84 for prev in previous_tags:
83 if not prev.name in tags: 85 if not prev.name in tags:
84 self.instance.tags.remove(prev) 86 self.instance.tags.remove(prev)
85 - 87 +
86 for tag in tags: 88 for tag in tags:
87 tag = tag.strip() 89 tag = tag.strip()
88 90
@@ -96,4 +98,4 @@ class PDFFileForm(forms.ModelForm): @@ -96,4 +98,4 @@ class PDFFileForm(forms.ModelForm):
96 if not new_tag in self.instance.tags.all(): 98 if not new_tag in self.instance.tags.all():
97 self.instance.tags.add(new_tag) 99 self.instance.tags.add(new_tag)
98 100
99 - return self.instance  
100 \ No newline at end of file 101 \ No newline at end of file
  102 + return self.instance
requirements.txt
@@ -37,4 +37,5 @@ django-cron==0.5.0 @@ -37,4 +37,5 @@ django-cron==0.5.0
37 django-crontab==0.7.1 37 django-crontab==0.7.1
38 python-dateutil==2.6.0 38 python-dateutil==2.6.0
39 channels==1.0.3 39 channels==1.0.3
40 -asgi_redis==1.0.0  
41 \ No newline at end of file 40 \ No newline at end of file
  41 +asgi_redis==1.0.0
  42 +file-resubmit==0.1.0
users/forms.py
@@ -5,6 +5,9 @@ from rolepermissions.shortcuts import assign_role @@ -5,6 +5,9 @@ from rolepermissions.shortcuts import assign_role
5 from django.contrib.auth import update_session_auth_hash 5 from django.contrib.auth import update_session_auth_hash
6 from django.core.validators import validate_email 6 from django.core.validators import validate_email
7 from django.core.exceptions import ValidationError 7 from django.core.exceptions import ValidationError
  8 +
  9 +from resubmit.widgets import ResubmitFileWidget
  10 +
8 from .models import User 11 from .models import User
9 12
10 class Validation(forms.ModelForm): 13 class Validation(forms.ModelForm):
@@ -19,7 +22,7 @@ class Validation(forms.ModelForm): @@ -19,7 +22,7 @@ class Validation(forms.ModelForm):
19 return email 22 return email
20 except ValidationError: 23 except ValidationError:
21 self._errors['email'] = [_('You must insert an email address')] 24 self._errors['email'] = [_('You must insert an email address')]
22 - 25 +
23 return ValueError 26 return ValueError
24 27
25 def clean_image(self): 28 def clean_image(self):
@@ -37,13 +40,13 @@ class Validation(forms.ModelForm): @@ -37,13 +40,13 @@ class Validation(forms.ModelForm):
37 def clean_password2(self): 40 def clean_password2(self):
38 password = self.cleaned_data.get("new_password") 41 password = self.cleaned_data.get("new_password")
39 password2 = self.cleaned_data.get("password2") 42 password2 = self.cleaned_data.get("password2")
40 - 43 +
41 if password and password2 and password != password2: 44 if password and password2 and password != password2:
42 self._errors['password2'] = [_('The confirmation password is incorrect.')] 45 self._errors['password2'] = [_('The confirmation password is incorrect.')]
43 46
44 return ValueError 47 return ValueError
45 -  
46 - return password2 48 +
  49 + return password2
47 50
48 class RegisterUserForm(Validation): 51 class RegisterUserForm(Validation):
49 new_password = forms.CharField(label=_('Password'), widget = forms.PasswordInput(render_value = True, attrs = {'placeholder': _('Password') + ' *'})) 52 new_password = forms.CharField(label=_('Password'), widget = forms.PasswordInput(render_value = True, attrs = {'placeholder': _('Password') + ' *'}))
@@ -53,11 +56,11 @@ class RegisterUserForm(Validation): @@ -53,11 +56,11 @@ class RegisterUserForm(Validation):
53 56
54 def save(self, commit=True): 57 def save(self, commit=True):
55 super(RegisterUserForm, self).save(commit=False) 58 super(RegisterUserForm, self).save(commit=False)
56 - 59 +
57 self.instance.set_password(self.cleaned_data['new_password']) 60 self.instance.set_password(self.cleaned_data['new_password'])
58 61
59 self.instance.save() 62 self.instance.save()
60 - 63 +
61 return self.instance 64 return self.instance
62 65
63 class Meta: 66 class Meta:
@@ -68,6 +71,7 @@ class RegisterUserForm(Validation): @@ -68,6 +71,7 @@ class RegisterUserForm(Validation):
68 'username': forms.TextInput(attrs = {'placeholder': _('Name') + ' *'}), 71 'username': forms.TextInput(attrs = {'placeholder': _('Name') + ' *'}),
69 'last_name': forms.TextInput(attrs = {'placeholder': _('Last Name') + ' *'}), 72 'last_name': forms.TextInput(attrs = {'placeholder': _('Last Name') + ' *'}),
70 'social_name': forms.TextInput(attrs = {'placeholder': _('Social Name')}), 73 'social_name': forms.TextInput(attrs = {'placeholder': _('Social Name')}),
  74 + 'image': ResubmitFileWidget(attrs={'accept':'image/*'}),
71 } 75 }
72 76
73 class ProfileForm(Validation): 77 class ProfileForm(Validation):
@@ -75,9 +79,9 @@ class ProfileForm(Validation): @@ -75,9 +79,9 @@ class ProfileForm(Validation):
75 79
76 def save(self, commit=True): 80 def save(self, commit=True):
77 super(ProfileForm, self).save(commit=False) 81 super(ProfileForm, self).save(commit=False)
78 - 82 +
79 self.instance.save() 83 self.instance.save()
80 - 84 +
81 return self.instance 85 return self.instance
82 86
83 class Meta: 87 class Meta:
@@ -86,7 +90,8 @@ class ProfileForm(Validation): @@ -86,7 +90,8 @@ class ProfileForm(Validation):
86 widgets = { 90 widgets = {
87 'description': forms.Textarea, 91 'description': forms.Textarea,
88 'username': forms.TextInput(attrs = {'readonly': 'readonly'}), 92 'username': forms.TextInput(attrs = {'readonly': 'readonly'}),
89 - 'last_name': forms.TextInput(attrs = {'readonly': 'readonly'}) 93 + 'last_name': forms.TextInput(attrs = {'readonly': 'readonly'}),
  94 + 'image': ResubmitFileWidget(attrs={'accept':'image/*'}),
90 } 95 }
91 96
92 class UserForm(Validation): 97 class UserForm(Validation):
@@ -98,19 +103,19 @@ class UserForm(Validation): @@ -98,19 +103,19 @@ class UserForm(Validation):
98 super(UserForm, self).__init__(*args, **kwargs) 103 super(UserForm, self).__init__(*args, **kwargs)
99 104
100 self.is_edit = is_update 105 self.is_edit = is_update
101 - 106 +
102 new_password = forms.CharField(label = _('Password'), widget = forms.PasswordInput(render_value = True), required = False) 107 new_password = forms.CharField(label = _('Password'), widget = forms.PasswordInput(render_value = True), required = False)
103 password2 = forms.CharField(label = _('Confirm Password'), widget = forms.PasswordInput(render_value = True), required = False) 108 password2 = forms.CharField(label = _('Confirm Password'), widget = forms.PasswordInput(render_value = True), required = False)
104 109
105 110
106 def save(self, commit=True): 111 def save(self, commit=True):
107 super(UserForm, self).save(commit=False) 112 super(UserForm, self).save(commit=False)
108 - 113 +
109 if not self.is_edit or self.cleaned_data['new_password'] != '': 114 if not self.is_edit or self.cleaned_data['new_password'] != '':
110 self.instance.set_password(self.cleaned_data['new_password']) 115 self.instance.set_password(self.cleaned_data['new_password'])
111 116
112 self.instance.save() 117 self.instance.save()
113 - 118 +
114 return self.instance 119 return self.instance
115 120
116 class Meta: 121 class Meta:
@@ -118,6 +123,7 @@ class UserForm(Validation): @@ -118,6 +123,7 @@ class UserForm(Validation):
118 fields = ['email', 'username', 'last_name', 'social_name', 'description', 'show_email', 'image', 'is_staff', 'is_active',] 123 fields = ['email', 'username', 'last_name', 'social_name', 'description', 'show_email', 'image', 'is_staff', 'is_active',]
119 widgets = { 124 widgets = {
120 'description': forms.Textarea, 125 'description': forms.Textarea,
  126 + 'image': ResubmitFileWidget(attrs={'accept':'image/*'}),
121 } 127 }
122 128
123 class ChangePassForm(Validation): 129 class ChangePassForm(Validation):
@@ -143,13 +149,13 @@ class ChangePassForm(Validation): @@ -143,13 +149,13 @@ class ChangePassForm(Validation):
143 149
144 def save(self, commit=True): 150 def save(self, commit=True):
145 super(ChangePassForm, self).save(commit=False) 151 super(ChangePassForm, self).save(commit=False)
146 - 152 +
147 self.instance.set_password(self.cleaned_data['new_password']) 153 self.instance.set_password(self.cleaned_data['new_password'])
148 154
149 update_session_auth_hash(self.request, self.instance) 155 update_session_auth_hash(self.request, self.instance)
150 156
151 self.instance.save() 157 self.instance.save()
152 - 158 +
153 return self.instance 159 return self.instance
154 160
155 class Meta: 161 class Meta:
@@ -173,7 +179,7 @@ class PassResetRequest(forms.Form): @@ -173,7 +179,7 @@ class PassResetRequest(forms.Form):
173 return email 179 return email
174 except ValidationError: 180 except ValidationError:
175 self._errors['email'] = [_('You must insert a valid email address')] 181 self._errors['email'] = [_('You must insert a valid email address')]
176 - 182 +
177 return ValueError 183 return ValueError
178 184
179 class SetPasswordForm(Validation): 185 class SetPasswordForm(Validation):
@@ -184,4 +190,4 @@ class SetPasswordForm(Validation): @@ -184,4 +190,4 @@ class SetPasswordForm(Validation):
184 190
185 class Meta: 191 class Meta:
186 model = User 192 model = User
187 - fields = []  
188 \ No newline at end of file 193 \ No newline at end of file
  194 + fields = []