Commit 5138168d328a0116c76b88d2d6fac2ea874999f7
1 parent
c45e4577
Exists in
master
and in
5 other branches
Adding create subject log [Issue: #247]
Showing
1 changed file
with
16 additions
and
1 deletions
Show diff stats
courses/views.py
... | ... | @@ -689,7 +689,11 @@ class UpdateTopicView(LoginRequiredMixin, HasRoleMixin, generic.UpdateView): |
689 | 689 | context['subjects'] = topic.subject.course.subjects.all() |
690 | 690 | return context |
691 | 691 | |
692 | -class CreateSubjectView(LoginRequiredMixin, HasRoleMixin, NotificationMixin, generic.edit.CreateView): | |
692 | +class CreateSubjectView(LoginRequiredMixin, HasRoleMixin, LogMixin, NotificationMixin, generic.edit.CreateView): | |
693 | + log_component = "course" | |
694 | + log_resource = "subject" | |
695 | + log_action = "create" | |
696 | + log_context = {} | |
693 | 697 | |
694 | 698 | allowed_roles = ['professor', 'system_admin'] |
695 | 699 | login_url = reverse_lazy("core:home") |
... | ... | @@ -721,6 +725,17 @@ class CreateSubjectView(LoginRequiredMixin, HasRoleMixin, NotificationMixin, gen |
721 | 725 | resource_slug = self.object.slug, actor=self.request.user, users= self.object.course.students.all(), |
722 | 726 | resource_link = reverse('course:view_subject', args=[self.object.slug])) |
723 | 727 | |
728 | + self.log_context['subject_id'] = self.object.id | |
729 | + self.log_context['subject_name'] = self.object.name | |
730 | + self.log_context['subject_slug'] = self.object.slug | |
731 | + self.log_context['course_id'] = course.id | |
732 | + self.log_context['course_name'] = course.name | |
733 | + self.log_context['course_slug'] = course.slug | |
734 | + self.log_context['course_category_id'] = course.category.id | |
735 | + self.log_context['course_category_name'] = course.category.name | |
736 | + | |
737 | + super(CreateSubjectView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | |
738 | + | |
724 | 739 | return super(CreateSubjectView, self).form_valid(form) |
725 | 740 | |
726 | 741 | ... | ... |