Commit fe09c7da9c9e507560f157699db4cb7ba11e0990
1 parent
d3a73423
Exists in
master
and in
3 other branches
added log for pdf file views and links views as well
Showing
2 changed files
with
33 additions
and
5 deletions
Show diff stats
links/views.py
... | ... | @@ -21,7 +21,7 @@ from topics.models import Topic |
21 | 21 | class CreateLinkView(LoginRequiredMixin, LogMixin, generic.edit.CreateView): |
22 | 22 | log_component = 'resources' |
23 | 23 | log_action = 'create' |
24 | - log_resource = 'file_link' | |
24 | + log_resource = 'links' | |
25 | 25 | log_context = {} |
26 | 26 | |
27 | 27 | login_url = reverse_lazy("users:login") |
... | ... | @@ -176,14 +176,17 @@ class DeleteLinkView(LoginRequiredMixin, LogMixin, generic.edit.DeleteView): |
176 | 176 | self.log_context['link_id'] = self.object.id |
177 | 177 | self.log_context['link_name'] = self.object.name |
178 | 178 | self.log_context['link_slug'] = self.object.slug |
179 | - | |
179 | + | |
180 | 180 | super(DeleteLinkView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) |
181 | 181 | |
182 | 182 | return reverse_lazy('subjects:view', kwargs = {'slug': self.object.topic.subject.slug}) |
183 | 183 | |
184 | 184 | |
185 | 185 | class DetailLinkView(LoginRequiredMixin, LogMixin, generic.detail.DetailView): |
186 | - | |
186 | + log_component = 'resources' | |
187 | + log_action = 'view' | |
188 | + log_resource = 'links' | |
189 | + log_context = {} | |
187 | 190 | login_url = reverse_lazy("users:login") |
188 | 191 | redirect_field_name = 'next' |
189 | 192 | |
... | ... | @@ -192,6 +195,11 @@ class DetailLinkView(LoginRequiredMixin, LogMixin, generic.detail.DetailView): |
192 | 195 | context_object_name = 'web_link' |
193 | 196 | |
194 | 197 | class UpdateLinkView(LoginRequiredMixin, LogMixin, generic.edit.UpdateView): |
198 | + | |
199 | + log_component = 'resources' | |
200 | + log_action = 'update' | |
201 | + log_resource = 'links' | |
202 | + log_context = {} | |
195 | 203 | model = Link |
196 | 204 | form_class = LinkForm |
197 | 205 | template_name = 'links/update.html' | ... | ... |
pdf_file/views.py
... | ... | @@ -19,9 +19,12 @@ from pendencies.forms import PendenciesForm |
19 | 19 | |
20 | 20 | |
21 | 21 | |
22 | -class ViewPDFFile(generic.TemplateView): | |
22 | +class ViewPDFFile(LoginRequiredMixin, LogMixin, generic.TemplateView): | |
23 | 23 | template_name='pdf_file/view.html' |
24 | - | |
24 | + log_component = 'resources' | |
25 | + log_action = 'view' | |
26 | + log_resource = 'pdf_file' | |
27 | + log_context = {} | |
25 | 28 | def dispatch(self, request, *args, **kwargs): |
26 | 29 | slug = self.kwargs.get('slug', '') |
27 | 30 | resource = get_object_or_404(Resource, slug = slug) |
... | ... | @@ -38,6 +41,23 @@ class ViewPDFFile(generic.TemplateView): |
38 | 41 | pdf_file = PDFFile.objects.get(slug=slug) |
39 | 42 | context['pdf_file'] = pdf_file |
40 | 43 | context['subject'] = pdf_file.topic.subject |
44 | + | |
45 | + | |
46 | + self.log_context['category_id'] = pdf_file.topic.subject.category.id | |
47 | + self.log_context['category_name'] = pdf_file.topic.subject.category.name | |
48 | + self.log_context['category_slug'] = pdf_file.topic.subject.category.slug | |
49 | + self.log_context['subject_id'] = pdf_file.topic.subject.id | |
50 | + self.log_context['subject_name'] = pdf_file.topic.subject.name | |
51 | + self.log_context['subject_slug'] = pdf_file.topic.subject.slug | |
52 | + self.log_context['topic_id'] = pdf_file.topic.id | |
53 | + self.log_context['topic_name'] = pdf_file.topic.name | |
54 | + self.log_context['topic_slug'] = pdf_file.topic.slug | |
55 | + self.log_context['pdf_id'] = pdf_file.id | |
56 | + self.log_context['pdf_name'] = pdf_file.name | |
57 | + self.log_context['pdf_slug'] = pdf_file.slug | |
58 | + | |
59 | + super(ViewPDFFile, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | |
60 | + | |
41 | 61 | return context |
42 | 62 | |
43 | 63 | ... | ... |