Commit a1f22d43b1820c8cb6494727b4f1961bde0061c9
Exists in
master
and in
5 other branches
Merge branch 'dev' of https://github.com/amadeusproject/amadeuslms into dev
Showing
9 changed files
with
208 additions
and
114 deletions
Show diff stats
courses/views.py
... | ... | @@ -164,7 +164,7 @@ class DeleteCourseView(LoginRequiredMixin, HasRoleMixin, generic.DeleteView): |
164 | 164 | return context |
165 | 165 | |
166 | 166 | |
167 | -class CourseView(LoginRequiredMixin, NotificationMixin, generic.DetailView): | |
167 | +class CourseView( NotificationMixin, generic.DetailView): | |
168 | 168 | |
169 | 169 | login_url = reverse_lazy("core:home") |
170 | 170 | redirect_field_name = 'next' |
... | ... | @@ -181,7 +181,7 @@ class CourseView(LoginRequiredMixin, NotificationMixin, generic.DetailView): |
181 | 181 | subjects = course.subjects.all() |
182 | 182 | elif has_role(self.request.user,'professor'): |
183 | 183 | subjects = course.subjects.filter(professors__in=[self.request.user]) |
184 | - elif has_role(self.request.user, 'student'): | |
184 | + elif has_role(self.request.user, 'student') or self.request.user is None: | |
185 | 185 | subjects = course.subjects.filter(visible=True) |
186 | 186 | context['subjects'] = subjects |
187 | 187 | |
... | ... | @@ -191,12 +191,16 @@ class CourseView(LoginRequiredMixin, NotificationMixin, generic.DetailView): |
191 | 191 | courses = self.request.user.courses_professors.all() |
192 | 192 | elif has_role(self.request.user, 'student'): |
193 | 193 | courses = self.request.user.courses_student.all() |
194 | + else: | |
195 | + courses = Course.objects.filter(public = True) | |
194 | 196 | |
195 | 197 | categorys_subjects = None |
196 | 198 | if has_role(self.request.user,'professor') or has_role(self.request.user,'system_admin'): |
197 | 199 | categorys_subjects = CategorySubject.objects.filter(subject_category__professors__name = self.request.user.name).distinct() |
198 | - else: | |
200 | + elif has_role(self.request.user, 'student'): | |
199 | 201 | categorys_subjects = CategorySubject.objects.filter(subject_category__students__name = self.request.user.name).distinct() |
202 | + else: | |
203 | + categorys_subjects = CategorySubject.objects.all().distinct() | |
200 | 204 | |
201 | 205 | subjects_category = Subject.objects.filter(category__name = self.request.GET.get('category')) |
202 | 206 | ... | ... |
users/forms.py
... | ... | @@ -45,7 +45,7 @@ class UpdateUserForm(forms.ModelForm): |
45 | 45 | |
46 | 46 | def validate_cpf(self, cpf): |
47 | 47 | cpf = ''.join(re.findall('\d', str(cpf))) |
48 | - | |
48 | + | |
49 | 49 | if cpfcnpj.validate(cpf): |
50 | 50 | return True |
51 | 51 | return False |
... | ... | @@ -71,4 +71,4 @@ class UpdateProfileForm(UpdateUserForm): |
71 | 71 | |
72 | 72 | class Meta: |
73 | 73 | model = User |
74 | - fields = ['username', 'name', 'email', 'birth_date', 'city', 'state', 'gender', 'cpf', 'phone', 'image'] | |
74 | + fields = ['username', 'name', 'email', 'birth_date', 'city', 'state', 'gender', 'cpf', 'phone', 'image', 'curriculum'] | ... | ... |
... | ... | @@ -0,0 +1,57 @@ |
1 | +{% extends 'users/profile.html' %} | |
2 | + | |
3 | +{% load static i18n %} | |
4 | +{% load widget_tweaks %} | |
5 | +{% load django_bootstrap_breadcrumbs %} | |
6 | + | |
7 | +{% block breadcrumbs %} | |
8 | + | |
9 | + {{ block.super }} | |
10 | + {% breadcrumb 'Edit' 'users:update_profile' %} | |
11 | + | |
12 | +{% endblock %} | |
13 | + | |
14 | +{% block content %} | |
15 | + {% if messages %} | |
16 | + {% for message in messages %} | |
17 | + <div class="alert alert-success alert-dismissible" role="alert"> | |
18 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |
19 | + <span aria-hidden="true">×</span> | |
20 | + </button> | |
21 | + <p>{{ message }}</p> | |
22 | + </div> | |
23 | + {% endfor %} | |
24 | + {% endif %} | |
25 | + <div class="row"> | |
26 | + <div class="col-md-12"> | |
27 | + <div class="well well-lg"> | |
28 | + <form method="post" action="" enctype="multipart/form-data"> | |
29 | + {% csrf_token %} | |
30 | + <div class="form-group"> | |
31 | + <label class="control-label" for="focusedInput1">{% trans 'Current Password' %}</label> | |
32 | + <input type="password" class="form-control" id="inputPassword" placeholder="Password"> | |
33 | + </div> | |
34 | + <div class="form-group"> | |
35 | + <label class="control-label" for="focusedInput1">{% trans 'New Password' %}</label> | |
36 | + <input type="password" class="form-control" id="inputPassword" placeholder="Password"> | |
37 | + </div> | |
38 | + <div class="form-group"> | |
39 | + <label class="control-label" for="focusedInput1">{% trans 'Confirmation' %}</label> | |
40 | + <input type="password" class="form-control" id="inputPassword" placeholder="Password"> | |
41 | + </div> | |
42 | + <div class="row"> | |
43 | + <div class="col-md-3 col-sm-2 col-xs-2"> | |
44 | + <input type="submit" value="{% trans 'Save' %}" class="btn btn-raised btn-block btn-success" /> | |
45 | + </div> | |
46 | + <div class="col-md-3 col-sm-2 col-xs-2"> | |
47 | + <a href="{% url 'users:profile' %}" class="btn btn-raised btn-block btn-danger" >{% trans 'Cancel' %}</a> | |
48 | + </div> | |
49 | + </div> | |
50 | + </form> | |
51 | + </div> | |
52 | + </div> | |
53 | + </div> | |
54 | + | |
55 | + | |
56 | + <br clear="all" /> | |
57 | +{% endblock %} | ... | ... |
users/templates/users/edit_profile.html
... | ... | @@ -46,7 +46,7 @@ |
46 | 46 | {% elif field.auto_id == 'id_is_staff' or field.auto_id == 'id_is_active' %} |
47 | 47 | <div class="checkbox"> |
48 | 48 | <label> |
49 | - {% render_field field type='checkbox' %} | |
49 | + {% render_field field type='checkbox' %} | |
50 | 50 | </label> |
51 | 51 | </div> |
52 | 52 | {% elif field.auto_id == 'id_cpf' %} |
... | ... | @@ -72,16 +72,16 @@ |
72 | 72 | {% endif %} |
73 | 73 | </div> |
74 | 74 | {% endfor %} |
75 | - <div class="col-md-offset-2 col-md-2 col-sm-2 col-xs-2"> | |
76 | - <input type="submit" value="{% trans 'Save' %}" class="btn btn-sm btn-success" /> | |
75 | + <div class="col-md-3 col-sm-2 col-xs-2"> | |
76 | + <input type="submit" value="{% trans 'Save' %}" class="btn btn-raised btn-block btn-success" /> | |
77 | 77 | </div> |
78 | - <div class="col-md-offset-3 col-md-2 col-sm-2 col-xs-2"> | |
79 | - <a href="{% url 'users:manage' %}" class="btn btn-sm btn-success" >{% trans 'Cancel' %}</a> | |
78 | + <div class="col-md-3 col-sm-2 col-xs-2"> | |
79 | + <a href="{% url 'users:profile' %}" class="btn btn-raised btn-block btn-danger" >{% trans 'Cancel' %}</a> | |
80 | 80 | </div> |
81 | 81 | </form> |
82 | 82 | </div> |
83 | 83 | </div> |
84 | 84 | </div> |
85 | - | |
85 | + | |
86 | 86 | <br clear="all" /> |
87 | 87 | {% endblock %} | ... | ... |
users/templates/users/profile.html
... | ... | @@ -14,13 +14,15 @@ |
14 | 14 | {% block sidebar %} |
15 | 15 | <div class="panel panel-primary navigation"> |
16 | 16 | <div class="panel-heading"> |
17 | - <h5>Profile</h5> | |
17 | + <h4>Menu</h4> | |
18 | 18 | </div> |
19 | 19 | <div class="panel-body"> |
20 | 20 | <ul class="nav nav-pills nav-stacked"> |
21 | - <li><a href="{% url 'app:index' %}">{% trans 'Home' %}</a></li> | |
22 | - <li><a href="{% url 'users:profile' %}">{% trans 'View Profile' %}</a></li> | |
23 | - <li><a href="{% url 'users:update_profile' %}">{% trans 'Edit Profile' %}</a></li> | |
21 | + <li><a href="{% url 'app:index' %}">{% trans 'Home page' %}</a></li> | |
22 | + <li><a href="{% url 'users:profile' %}">{% trans 'View Profile' %}</a></li> | |
23 | + <li><a href="{% url 'users:update_profile' %}">{% trans 'Edit Profile' %}</a></li> | |
24 | + <li><a href="{% url 'users:change_password' %}">{% trans 'Change Password' %}</a></li> | |
25 | + <li><a href="{% url 'users:remove_account' %}">{% trans 'Remove account' %}</a></li> | |
24 | 26 | </ul> |
25 | 27 | </div> |
26 | 28 | </div> |
... | ... | @@ -37,106 +39,85 @@ |
37 | 39 | </div> |
38 | 40 | {% endfor %} |
39 | 41 | {% endif %} |
40 | - | |
41 | - <div class="row"> | |
42 | - <div class="col-lg-offset-4 col-lg-2"> | |
43 | - <img src="" class="img-responsive center-block " alt="logo amadeus"> | |
44 | - </div> | |
45 | - </div> | |
46 | 42 | <div class="row"> |
47 | 43 | <div class="col-lg-12"> |
48 | - <div class="card"> | |
49 | - <div class="card-content"> | |
50 | - <div class="card-body"> | |
51 | - <div class="row"> | |
52 | - <div class="col-md-4"> | |
53 | - <img src="{{ user.image_url }}" class="img-responsive center-block img-circle" alt="foto perfil" style="max-height:174px"> | |
54 | - </div> | |
55 | - <div class="col-md-8"> | |
56 | - <table class="table table-hover table-edited"> | |
57 | - <tbody> | |
58 | - <tr> | |
59 | - <td>Status:</td> | |
60 | - <td>Offline</td> | |
61 | - </tr> | |
62 | - <tr> | |
63 | - <td>Nome:</td> | |
64 | - <td>{{user}}</td> | |
65 | - </tr> | |
66 | - <tr> | |
67 | - <td>Login:</td> | |
68 | - <td>{{user.username}}</td> | |
69 | - </tr> | |
70 | - <tr> | |
71 | - <td>Email:</td> | |
72 | - <td>{{user.email}}</td> | |
73 | - </tr> | |
74 | - </tbody> | |
75 | - </table> | |
76 | - </div> | |
77 | - </div> | |
78 | - <div class="row"> | |
79 | - <div class="col-md-10 col-md-offset-1"> | |
80 | - <table class="table table-hover table-edited"> | |
81 | - <tbody> | |
82 | - <tr> | |
83 | - <td>Tipo de usuário:</td> | |
84 | - <td>{{use.type_profile}}</td> | |
85 | - </tr> | |
86 | - <tr> | |
87 | - <td>CPF:</td> | |
88 | - <td>{{user.cpf}}</td> | |
89 | - </tr> | |
90 | - <tr> | |
91 | - <td>Número de telefone:</td> | |
92 | - <td>{{user.phone}}</td> | |
93 | - </tr> | |
94 | - <tr> | |
95 | - <td>Sexo:</td> | |
96 | - <td>{{user.gender}}</td> | |
97 | - </tr> | |
98 | - <tr> | |
99 | - <td>Data de Nascimento:</td> | |
100 | - <td>{{user.birth_date}}</td> | |
101 | - </tr> | |
102 | - <tr> | |
103 | - <td>Estado e Cidade:</td> | |
104 | - <td>{{user.state}} - {{user.city}}</td> | |
105 | - </tr> | |
106 | - <tr> | |
107 | - <td>Titulação:</td> | |
108 | - <td>Mestrado</td> | |
109 | - </tr> | |
110 | - <tr> | |
111 | - <td>Ano:</td> | |
112 | - <td>2012</td> | |
113 | - </tr> | |
114 | - <tr> | |
115 | - <td>Instituição:</td> | |
116 | - <td>UFPE</td> | |
117 | - </tr> | |
118 | - <tr> | |
119 | - <td>Currículo:</td> | |
120 | - <td>-</td> | |
121 | - </tr> | |
122 | - </tbody> | |
123 | - </table> | |
124 | - </div> | |
125 | - </div> | |
44 | + <div class="well well-lg"> | |
45 | + <div class="row"> | |
46 | + <div class="col-md-4"> | |
47 | + <img src="{{ user.image_url }}" class="img-responsive center-block img-circle" alt="foto perfil" style="max-height:174px"> | |
126 | 48 | </div> |
127 | - </div> | |
128 | - <footer class="card-footer"> | |
129 | - <div class="col-md-6"> | |
130 | - <a href="{% url 'users:update_profile' %}" class="btn btn-flat">{% trans 'Edit Profile' %}</a> | |
49 | + <div class="col-md-8"> | |
50 | + <table class="table table-hover table-edited"> | |
51 | + <tbody> | |
52 | + <tr> | |
53 | + <td>Status:</td> | |
54 | + <td>Offline</td> | |
55 | + </tr> | |
56 | + <tr> | |
57 | + <td>Nome:</td> | |
58 | + <td>{{user}}</td> | |
59 | + </tr> | |
60 | + <tr> | |
61 | + <td>Login:</td> | |
62 | + <td>{{user.username}}</td> | |
63 | + </tr> | |
64 | + <tr> | |
65 | + <td>Email:</td> | |
66 | + <td>{{user.email}}</td> | |
67 | + </tr> | |
68 | + </tbody> | |
69 | + </table> | |
131 | 70 | </div> |
132 | - <div class="col-md-6"> | |
133 | - <button class="btn btn-flat btn-danger pull-right">{% trans 'Delete Account' %}</button> | |
71 | + </div> | |
72 | + <div class="row"> | |
73 | + <div class="col-md-10 col-md-offset-1"> | |
74 | + <table class="table table-hover table-edited"> | |
75 | + <tbody> | |
76 | + <tr> | |
77 | + <td>Tipo de usuário:</td> | |
78 | + <td>{{use.type_profile}}</td> | |
79 | + </tr> | |
80 | + <tr> | |
81 | + <td>CPF:</td> | |
82 | + <td>{{user.cpf}}</td> | |
83 | + </tr> | |
84 | + <tr> | |
85 | + <td>Número de telefone:</td> | |
86 | + <td>{{user.phone}}</td> | |
87 | + </tr> | |
88 | + <tr> | |
89 | + <td>Sexo:</td> | |
90 | + <td>{{user.gender}}</td> | |
91 | + </tr> | |
92 | + <tr> | |
93 | + <td>Data de Nascimento:</td> | |
94 | + <td>{{user.birth_date}}</td> | |
95 | + </tr> | |
96 | + <tr> | |
97 | + <td>Estado e Cidade:</td> | |
98 | + <td>{{user.state}} - {{user.city}}</td> | |
99 | + </tr> | |
100 | + <tr> | |
101 | + <td>Titulação:</td> | |
102 | + <td>Mestrado</td> | |
103 | + </tr> | |
104 | + <tr> | |
105 | + <td>Ano:</td> | |
106 | + <td>2012</td> | |
107 | + </tr> | |
108 | + <tr> | |
109 | + <td>Instituição:</td> | |
110 | + <td>UFPE</td> | |
111 | + </tr> | |
112 | + <tr> | |
113 | + <td>Currículo:</td> | |
114 | + <td>-</td> | |
115 | + </tr> | |
116 | + </tbody> | |
117 | + </table> | |
134 | 118 | </div> |
135 | - </footer> | |
136 | - | |
119 | + </div> | |
137 | 120 | </div> |
138 | - | |
139 | - | |
140 | 121 | </div> |
141 | 122 | </div> |
142 | 123 | {% endblock %} | ... | ... |
... | ... | @@ -0,0 +1,44 @@ |
1 | +{% extends 'users/profile.html' %} | |
2 | + | |
3 | +{% load static i18n %} | |
4 | +{% load widget_tweaks %} | |
5 | +{% load django_bootstrap_breadcrumbs %} | |
6 | + | |
7 | +{% block breadcrumbs %} | |
8 | + | |
9 | + {{ block.super }} | |
10 | + {% breadcrumb 'Edit' 'users:update_profile' %} | |
11 | + | |
12 | +{% endblock %} | |
13 | + | |
14 | +{% block content %} | |
15 | + {% if messages %} | |
16 | + {% for message in messages %} | |
17 | + <div class="alert alert-success alert-dismissible" role="alert"> | |
18 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |
19 | + <span aria-hidden="true">×</span> | |
20 | + </button> | |
21 | + <p>{{ message }}</p> | |
22 | + </div> | |
23 | + {% endfor %} | |
24 | + {% endif %} | |
25 | + <div class="row"> | |
26 | + <div class="col-md-12"> | |
27 | + <div class="well well-lg"> | |
28 | + <h2>Voce tem certeza que deseja remover esta conta?</h2> | |
29 | + <p>Todos os seus dados serão removidos e não haverá como recupera-los posteriormente.</p> | |
30 | + <div class="row"> | |
31 | + <div class="col-md-3 col-sm-2 col-xs-2"> | |
32 | + <a href="#" class="btn btn-raised btn-block btn-success" >{% trans 'Remove' %}</a> | |
33 | + </div> | |
34 | + <div class="col-md-3 col-sm-2 col-xs-2"> | |
35 | + <a href="{% url 'users:profile' %}" class="btn btn-raised btn-block btn-danger" >{% trans 'Cancel' %}</a> | |
36 | + </div> | |
37 | + </div> | |
38 | + </div> | |
39 | + </div> | |
40 | + </div> | |
41 | + | |
42 | + | |
43 | + <br clear="all" /> | |
44 | +{% endblock %} | ... | ... |
users/templates/users/update.html
... | ... | @@ -24,7 +24,7 @@ |
24 | 24 | </div> |
25 | 25 | {% endfor %} |
26 | 26 | {% endif %} |
27 | - | |
27 | + | |
28 | 28 | <div class="card"> |
29 | 29 | <div class="card-content"> |
30 | 30 | <div class="card-body"> |
... | ... | @@ -51,7 +51,7 @@ |
51 | 51 | |
52 | 52 | {% elif field.auto_id == 'id_phone' %} |
53 | 53 | {% render_field field class='form-control' onkeypress='campoNumerico(this,event); formatarTelefone(this,event);' %} |
54 | - | |
54 | + | |
55 | 55 | {% elif field.auto_id == 'id_is_staff' or field.auto_id == 'id_is_active' %} |
56 | 56 | <div class="checkbox"> |
57 | 57 | <label for="{{ field.auto_id }}"> |
... | ... | @@ -77,10 +77,10 @@ |
77 | 77 | </div> |
78 | 78 | {% endfor %} |
79 | 79 | <div class="col-md-offset-2 col-md-2 col-sm-2 col-xs-2"> |
80 | - <input type="submit" value="{% trans 'Save' %}" class="btn btn-sm btn-success" /> | |
80 | + <input type="submit" value="{% trans 'Save' %}" class="btn btn-raised btn-success" /> | |
81 | 81 | </div> |
82 | 82 | <div class="col-md-offset-3 col-md-2 col-sm-2 col-xs-2"> |
83 | - <a href="{% url 'users:manage' %}" class="btn btn-sm btn-success" >{% trans 'Cancel' %}</a> | |
83 | + <a href="{% url 'users:manage' %}" class="btn btn-raised btn-danger" >{% trans 'Cancel' %}</a> | |
84 | 84 | </div> |
85 | 85 | </form> |
86 | 86 | </div> | ... | ... |
users/urls.py
... | ... | @@ -11,5 +11,7 @@ urlpatterns = [ |
11 | 11 | url(r'^profile/$', views.Profile.as_view(), name='profile'), |
12 | 12 | # |
13 | 13 | url(r'^profile/update/$', views.UpdateProfile.as_view(), name='update_profile'), |
14 | - url(r'^profile/delete/$', views.DeleteUser.as_view(), name='delete_profile'), | |
14 | + url(r'^profile/change_password/$', views.Change_password.as_view(), name='change_password'), | |
15 | + url(r'^profile/remove_account/$', views.Remove_account.as_view(), name='remove_account'), | |
16 | + url(r'^profile/delete/$', views.DeleteUser.as_view(), name='delete_profile'), | |
15 | 17 | ] | ... | ... |
users/views.py
... | ... | @@ -102,6 +102,12 @@ def delete(request,username): |
102 | 102 | return redirect('users:manage') |
103 | 103 | |
104 | 104 | |
105 | +class Change_password(generic.TemplateView): | |
106 | + template_name = 'users/change_password.html' | |
107 | + | |
108 | +class Remove_account(generic.TemplateView): | |
109 | + template_name = 'users/remove_account.html' | |
110 | + | |
105 | 111 | |
106 | 112 | class UpdateProfile(LoginRequiredMixin, generic.edit.UpdateView): |
107 | 113 | ... | ... |