Commit e4a76797a091fe7940dcb549e91ce3d011384799
1 parent
66eb7028
Exists in
master
and in
5 other branches
Included code to show in the my courses template breadcrumb what was searched by…
… the user [Issue:#438]
Showing
1 changed file
with
8 additions
and
3 deletions
Show diff stats
courses/views.py
| ... | ... | @@ -71,10 +71,10 @@ class IndexView(LoginRequiredMixin, NotificationMixin, generic.ListView): |
| 71 | 71 | def get_queryset(self): |
| 72 | 72 | result = super(IndexView, self).get_queryset() |
| 73 | 73 | |
| 74 | - course_search = self.request.GET.get('q', None) | |
| 74 | + self.course_search = self.request.GET.get('q', None) | |
| 75 | 75 | category_search = self.request.GET.get('category', None) |
| 76 | - if course_search: | |
| 77 | - query_list = course_search.split() | |
| 76 | + if self.course_search: | |
| 77 | + query_list = self.course_search.split() | |
| 78 | 78 | result = result.filter( |
| 79 | 79 | reduce(operator.and_, |
| 80 | 80 | (Q(name__icontains=q) for q in query_list)) |
| ... | ... | @@ -99,8 +99,13 @@ class IndexView(LoginRequiredMixin, NotificationMixin, generic.ListView): |
| 99 | 99 | elif has_role(self.request.user, 'student'): |
| 100 | 100 | list_courses = self.get_queryset().filter(students__in = [self.request.user]).order_by('name') |
| 101 | 101 | |
| 102 | + translated = _('You searched for... ') | |
| 102 | 103 | context['categorys_courses'] = course_category(list_courses) |
| 103 | 104 | context['title'] = _('Courses | Amadeus') |
| 105 | + if self.course_search: | |
| 106 | + context['search'] = translated + self.course_search | |
| 107 | + else: | |
| 108 | + context['search'] = "" | |
| 104 | 109 | return context |
| 105 | 110 | |
| 106 | 111 | class AllCoursesView(LoginRequiredMixin, NotificationMixin, generic.ListView): | ... | ... |