Commit 027410af29990626f7f7badbbb20e9084090f736

Authored by Zambom
1 parent 2ef81f0a

Adding search log

Showing 1 changed file with 15 additions and 3 deletions   Show diff stats
subjects/views.py
... ... @@ -529,6 +529,9 @@ class SubjectSubscribeView(LoginRequiredMixin, LogMixin, TemplateView):
529 529 log_resource = 'subject'
530 530 log_context = {}
531 531  
  532 + login_url = reverse_lazy("users:login")
  533 + redirect_field_name = 'next'
  534 +
532 535 template_name = 'subjects/subscribe.html'
533 536  
534 537 def get_context_data(self, **kwargs):
... ... @@ -559,8 +562,15 @@ class SubjectSubscribeView(LoginRequiredMixin, LogMixin, TemplateView):
559 562 return JsonResponse({'url':reverse_lazy('subjects:index')})
560 563  
561 564  
562   -class SubjectSearchView(LoginRequiredMixin, ListView):
  565 +class SubjectSearchView(LoginRequiredMixin, LogMixin, ListView):
  566 + log_component = 'subject'
  567 + log_action = 'search'
  568 + log_resource = 'subject/resources'
  569 + log_context = {}
  570 +
563 571 login_url = reverse_lazy("users:login")
  572 + redirect_field_name = 'next'
  573 +
564 574 template_name = 'subjects/list_search.html'
565 575 context_object_name = 'subjects'
566 576 paginate_by = 10
... ... @@ -586,8 +596,7 @@ class SubjectSearchView(LoginRequiredMixin, ListView):
586 596  
587 597 self.tags = tags
588 598 tags = tags.split(" ")
589   -
590   -
  599 +
591 600 subjects = Subject.objects.filter(tags__name__in=tags)
592 601 #pk = self.request.user.pk
593 602 #my_subjects = Subject.objects.filter(Q(students__pk=pk) | Q(professor__pk=pk) | Q(category__coordinators__pk=pk) & Q(tags__name__in=tags) ).distinct()
... ... @@ -613,6 +622,9 @@ class SubjectSearchView(LoginRequiredMixin, ListView):
613 622  
614 623 context['subjects_menu_active'] = 'subjects_menu_active'
615 624  
  625 + self.log_context['search_for'] = self.tags
  626 + super(SubjectSearchView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context)
  627 +
616 628 return context
617 629  
618 630 @log_decorator_ajax('subject', 'view', 'subject')
... ...