Commit f6815482ea736ac68dee5cb7ee51a118c24966da
1 parent
4521f98c
Exists in
master
and in
5 other branches
ajusting some things in view index courses
Showing
2 changed files
with
39 additions
and
29 deletions
Show diff stats
courses/templates/course/index.html
... | ... | @@ -102,17 +102,19 @@ |
102 | 102 | <h4 style="color:white">{{course.name}}</h4> |
103 | 103 | </a> |
104 | 104 | </div> |
105 | - <div class="col-xs-4 col-md-3" id="divMoreActions"> | |
106 | - <div class="btn-group"> | |
107 | - <button class="btn btn-default btn-sm dropdown-toggle" type="button" id="moreActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> | |
108 | - <i class="fa fa-ellipsis-v fa-2x" aria-hidden="true"></i> | |
109 | - </button> | |
110 | - <ul class="dropdown-menu" aria-labelledby="moreActions"> | |
111 | - <li><a href="javascript:void(0)" data-toggle="modal" data-target="#myModal4"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i> Replicate</a></li> | |
112 | - <li><a href="javascript:void(0)" data-toggle="modal" data-target="#removeCourse"><i class="fa fa-trash fa-fw" aria-hidden="true"></i> Remove</a></li> | |
113 | - </ul> | |
114 | - </div> | |
115 | - </div> | |
105 | + {% if user|has_role:'professor, system_admin' %} | |
106 | + <div class="col-xs-4 col-md-3" id="divMoreActions"> | |
107 | + <div class="btn-group"> | |
108 | + <button class="btn btn-default btn-sm dropdown-toggle" type="button" id="moreActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> | |
109 | + <i class="fa fa-ellipsis-v fa-2x" aria-hidden="true"></i> | |
110 | + </button> | |
111 | + <ul class="dropdown-menu" aria-labelledby="moreActions"> | |
112 | + <li><a href="javascript:void(0)" data-toggle="modal" data-target="#myModal4"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i> Replicate</a></li> | |
113 | + <li><a href="javascript:void(0)" data-toggle="modal" data-target="#removeCourse"><i class="fa fa-trash fa-fw" aria-hidden="true"></i> Remove</a></li> | |
114 | + </ul> | |
115 | + </div> | |
116 | + </div> | |
117 | + {% endif %} | |
116 | 118 | </div> |
117 | 119 | </div> |
118 | 120 | <div class="panel-collapse collapseOne collapse in" role="tabpanel" aria-labelledby="headingOne" aria-expanded="true" aria-hidden="false" tabindex="0"> |
... | ... | @@ -147,23 +149,19 @@ |
147 | 149 | <h4 style="color:white">{{course.name}}</h4> |
148 | 150 | </a> |
149 | 151 | </div> |
150 | - <div class="col-xs-4 col-md-3" id="divMoreActions"> | |
151 | - <div class="btn-group"> | |
152 | - <button type="button" class="btn btn-default btn-sm eye" data-toggle="tooltip" data-placement="bottom" title="Visible"> | |
153 | - <i class="fa fa-eye fa-2x" aria-hidden="true"></i> | |
154 | - </button> | |
155 | - | |
156 | - </div> | |
157 | - <div class="btn-group"> | |
158 | - <button class="btn btn-default btn-sm dropdown-toggle" type="button" id="moreActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> | |
159 | - <i class="fa fa-ellipsis-v fa-2x" aria-hidden="true"></i> | |
160 | - </button> | |
161 | - <ul class="dropdown-menu" aria-labelledby="moreActions"> | |
162 | - <li><a href="javascript:void(0)" data-toggle="modal" data-target="#myModal4"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i> Replicate</a></li> | |
163 | - <li><a href="javascript:void(0)" data-toggle="modal" data-target="#removeCourse"><i class="fa fa-trash fa-fw" aria-hidden="true"></i> Remove</a></li> | |
164 | - </ul> | |
165 | - </div> | |
166 | - </div> | |
152 | + {% if user|has_role:'professor, system_admin' %} | |
153 | + <div class="col-xs-4 col-md-3" id="divMoreActions"> | |
154 | + <div class="btn-group"> | |
155 | + <button class="btn btn-default btn-sm dropdown-toggle" type="button" id="moreActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> | |
156 | + <i class="fa fa-ellipsis-v fa-2x" aria-hidden="true"></i> | |
157 | + </button> | |
158 | + <ul class="dropdown-menu" aria-labelledby="moreActions"> | |
159 | + <li><a href="javascript:void(0)" data-toggle="modal" data-target="#myModal4"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i> Replicate</a></li> | |
160 | + <li><a href="javascript:void(0)" data-toggle="modal" data-target="#removeCourse"><i class="fa fa-trash fa-fw" aria-hidden="true"></i> Remove</a></li> | |
161 | + </ul> | |
162 | + </div> | |
163 | + </div> | |
164 | + {% endif %} | |
167 | 165 | </div> |
168 | 166 | </div> |
169 | 167 | <div class="panel-collapse collapseOne collapse in" role="tabpanel" aria-labelledby="headingOne" aria-expanded="true" aria-hidden="false" tabindex="0"> | ... | ... |
courses/views.py
... | ... | @@ -33,7 +33,7 @@ class IndexView(LoginRequiredMixin, NotificationMixin, generic.ListView): |
33 | 33 | list_courses = None |
34 | 34 | categorys_courses = None |
35 | 35 | if has_role(self.request.user,'professor') or has_role(self.request.user,'system_admin'): |
36 | - list_courses = Course.objects.filter(professors__name = self.request.user.name) | |
36 | + list_courses = Course.objects.filter(professors__name = self.request.user.name).order_by('name') | |
37 | 37 | categorys_courses = CourseCategory.objects.filter(course_category__professors__name = self.request.user.name).distinct() |
38 | 38 | else: |
39 | 39 | list_courses = Course.objects.filter(students__name = self.request.user.name) |
... | ... | @@ -63,6 +63,18 @@ class IndexView(LoginRequiredMixin, NotificationMixin, generic.ListView): |
63 | 63 | |
64 | 64 | return context |
65 | 65 | |
66 | + def get_queryset(self): | |
67 | + try: | |
68 | + name = self.kwargs['q'] | |
69 | + except: | |
70 | + name = '' | |
71 | + if (name != ''): | |
72 | + object_list = Course.objects.filter(name__icontains = name) | |
73 | + else: | |
74 | + object_list = Course.objects.all() | |
75 | + print(object_list) | |
76 | + return object_list | |
77 | + | |
66 | 78 | class CreateCourseView(LoginRequiredMixin, HasRoleMixin, NotificationMixin,generic.edit.CreateView): |
67 | 79 | |
68 | 80 | allowed_roles = ['professor', 'system_admin'] | ... | ... |