Commit 762529b49b971baa20356080c24d6d4b261c6465
Committed by
Sergio Oliveira
1 parent
cc3ce07f
Exists in
master
and in
39 other branches
Removed email from creation form
Removed e-mail field from form since it's not gonna be updated Signed-off-by: Carlos Oliveira <carlospecter@gmail.com> Signed-off-by: Sergio Oliveira <sergio@tracy.com.br>
Showing
2 changed files
with
4 additions
and
25 deletions
Show diff stats
colab/accounts/forms.py
@@ -32,7 +32,7 @@ class UserForm(forms.ModelForm): | @@ -32,7 +32,7 @@ class UserForm(forms.ModelForm): | ||
32 | # Forces username to be lowercase always | 32 | # Forces username to be lowercase always |
33 | widget=forms.TextInput(attrs={'style' : 'text-transform: lowercase;'}), | 33 | widget=forms.TextInput(attrs={'style' : 'text-transform: lowercase;'}), |
34 | ) | 34 | ) |
35 | - required = ('first_name', 'last_name', 'email', 'username') | 35 | + required = ('first_name', 'last_name', 'username') |
36 | 36 | ||
37 | class Meta: | 37 | class Meta: |
38 | model = User | 38 | model = User |
@@ -49,35 +49,17 @@ class UserForm(forms.ModelForm): | @@ -49,35 +49,17 @@ class UserForm(forms.ModelForm): | ||
49 | 49 | ||
50 | 50 | ||
51 | class UserCreationForm(UserForm): | 51 | class UserCreationForm(UserForm): |
52 | - email = forms.EmailField( | ||
53 | - | ||
54 | - # Forces email to be a read-only field | ||
55 | - widget=forms.TextInput(attrs={'readonly': 'readonly'}) | ||
56 | - ) | ||
57 | - | ||
58 | - def __init__(self, *args, **kwargs): | ||
59 | - self.original_email = kwargs.pop('email', None) | ||
60 | - super(UserCreationForm, self).__init__(*args, **kwargs) | ||
61 | - | ||
62 | - def clean_email(self): | ||
63 | - form_email = self.cleaned_data['email'] | ||
64 | - | ||
65 | - if form_email != self.original_email: | ||
66 | - raise forms.ValidationError('This is not the original email.') | ||
67 | - | ||
68 | - return form_email | ||
69 | - | ||
70 | 52 | ||
71 | def clean_username(self): | 53 | def clean_username(self): |
72 | username = self.cleaned_data['username'] | 54 | username = self.cleaned_data['username'] |
73 | username = username.strip() | 55 | username = username.strip() |
74 | if not username: | 56 | if not username: |
75 | - raise forms.ValidationError('This field should not be blank.') | 57 | + raise forms.ValidationError(_('This field should not be blank.')) |
76 | return username | 58 | return username |
77 | 59 | ||
78 | class Meta: | 60 | class Meta: |
79 | model = User | 61 | model = User |
80 | - fields = ('first_name', 'last_name', 'email', 'username') | 62 | + fields = ('first_name', 'last_name', 'username') |
81 | 63 | ||
82 | 64 | ||
83 | class UserUpdateForm(UserForm): | 65 | class UserUpdateForm(UserForm): |
colab/accounts/views.py
@@ -138,8 +138,6 @@ def signup(request): | @@ -138,8 +138,6 @@ def signup(request): | ||
138 | user_form = UserCreationForm() | 138 | user_form = UserCreationForm() |
139 | lists_form = ListsForm() | 139 | lists_form = ListsForm() |
140 | 140 | ||
141 | - user_form.fields['email'].initial = user.email | ||
142 | - | ||
143 | return render(request, 'accounts/user_create_form.html', | 141 | return render(request, 'accounts/user_create_form.html', |
144 | {'user_form': user_form, 'lists_form': lists_form}) | 142 | {'user_form': user_form, 'lists_form': lists_form}) |
145 | 143 | ||
@@ -152,8 +150,7 @@ def signup(request): | @@ -152,8 +150,7 @@ def signup(request): | ||
152 | 150 | ||
153 | user = user_form.save(commit=False) | 151 | user = user_form.save(commit=False) |
154 | user.needs_update = False | 152 | user.needs_update = False |
155 | - update_fields = ['first_name', 'last_name', 'username', 'needs_update'] | ||
156 | - user.save(update_fields=update_fields) | 153 | + user.save() |
157 | 154 | ||
158 | # Check if the user's email have been used previously | 155 | # Check if the user's email have been used previously |
159 | # in the mainling lists to link the user to old messages | 156 | # in the mainling lists to link the user to old messages |