Commit 92b0f143e7a7990132c5826f21e1d7494b5857f6
1 parent
e64fc7dd
Exists in
master
and in
2 other branches
added log for dashboards (both category and admin)
Showing
1 changed file
with
20 additions
and
4 deletions
Show diff stats
dashboards/views.py
... | ... | @@ -20,9 +20,19 @@ from collections import OrderedDict |
20 | 20 | from categories.models import Category |
21 | 21 | |
22 | 22 | |
23 | -class GeneralView(generic.TemplateView): | |
23 | +from log.mixins import LogMixin | |
24 | +from log.decorators import log_decorator_ajax | |
25 | +from log.models import Log | |
26 | + | |
27 | + | |
28 | +class GeneralView(LogMixin, generic.TemplateView): | |
24 | 29 | template_name = "dashboards/general.html" |
25 | 30 | |
31 | + log_component = "General_Dashboard" | |
32 | + log_action = "view" | |
33 | + log_resource = "General_Dashboard" | |
34 | + log_context = {} | |
35 | + | |
26 | 36 | def dispatch(self, request, *args, **kwargs): |
27 | 37 | |
28 | 38 | if not request.user.is_staff: |
... | ... | @@ -33,7 +43,7 @@ class GeneralView(generic.TemplateView): |
33 | 43 | def get_context_data(self, **kwargs): |
34 | 44 | context = {} |
35 | 45 | |
36 | - | |
46 | + self.createLog(actor = self.request.user) | |
37 | 47 | context['months'] = self.get_last_twelve_months() |
38 | 48 | |
39 | 49 | return context |
... | ... | @@ -57,15 +67,21 @@ class GeneralView(generic.TemplateView): |
57 | 67 | return months |
58 | 68 | |
59 | 69 | |
60 | -class CategoryView(generic.TemplateView): | |
70 | +class CategoryView(LogMixin, generic.TemplateView): | |
61 | 71 | template_name = "dashboards/category.html" |
62 | 72 | |
73 | + log_component = "Category_Dashboard" | |
74 | + log_action = "view" | |
75 | + log_resource = "Category_Dashboard" | |
76 | + log_context = {} | |
77 | + | |
63 | 78 | def dispatch(self, request, *args, **kwargs): |
64 | 79 | return super(CategoryView, self).dispatch(request, *args, **kwargs) |
65 | 80 | |
66 | 81 | def get_context_data(self, **kwargs): |
67 | 82 | context = {} |
68 | - | |
83 | + self.createLog(actor = self.request.user) | |
84 | + | |
69 | 85 | context['categories'] = self.categories_associated_with_user(self.request.user) |
70 | 86 | |
71 | 87 | return context | ... | ... |