Commit 0fb0a9e59e06537c76636efca5a225a489003fc1
1 parent
e2925990
Exists in
master
and in
5 other branches
Validating cpf in forms.py #14
Showing
2 changed files
with
2 additions
and
21 deletions
Show diff stats
users/forms.py
... | ... | @@ -27,25 +27,6 @@ class ProfileForm(forms.ModelForm): |
27 | 27 | } |
28 | 28 | |
29 | 29 | class UserForm(RegisterUserForm): |
30 | - def save(self, commit=True): | |
31 | - super(UserForm, self).save() | |
32 | - | |
33 | - if not self.instance.image: | |
34 | - self.instance.image = os.path.join(os.path.dirname(settings.BASE_DIR), 'uploads', 'no_image.jpg') | |
35 | - | |
36 | - self.instance.set_password(self.cleaned_data['password1']) | |
37 | - self.instance.save() | |
38 | - | |
39 | - if self.instance.is_staff: | |
40 | - assign_role(self.instance, 'system_admin') | |
41 | - elif self.instance.type_profile == 2: | |
42 | - assign_role(self.instance, 'student') | |
43 | - elif self.instance.type_profile == 1: | |
44 | - assign_role(self.instance, 'professor') | |
45 | - | |
46 | - self.instance.save() | |
47 | - | |
48 | - return self.instance | |
49 | 30 | |
50 | 31 | class Meta: |
51 | 32 | model = User | ... | ... |
users/templates/users/create.html
... | ... | @@ -60,8 +60,8 @@ |
60 | 60 | {% render_field field class='form-control' %} |
61 | 61 | {% endif %} |
62 | 62 | <span id="helpBlock" class="help-block">{{ field.help_text }}</span> |
63 | - {% if field.errors.length > 0 %} | |
64 | - <div class="alert alert-danger alert-dismissible" role="alert"> | |
63 | + {% if field.errors %} | |
64 | + <div class="alert alert-danger alert-dismissible col-md-offset-4 col-md-8" role="alert"> | |
65 | 65 | <button type="button" class="close" data-dismiss="alert" aria-label="Close"> |
66 | 66 | <span aria-hidden="true">×</span> |
67 | 67 | </button> | ... | ... |