diff --git a/courses/templates/subject/form_view_teacher.html b/courses/templates/subject/form_view_teacher.html index 2cb437c..4ffef8e 100644 --- a/courses/templates/subject/form_view_teacher.html +++ b/courses/templates/subject/form_view_teacher.html @@ -21,7 +21,7 @@ {% professor_subject topic.subject user as dropdown_topic %} {% if dropdown_topic %} diff --git a/courses/templates/topic/replicate.html b/courses/templates/topic/replicate.html new file mode 100644 index 0000000..d0fb6a9 --- /dev/null +++ b/courses/templates/topic/replicate.html @@ -0,0 +1,38 @@ +{% extends 'subject/index.html' %} + +{% load static i18n permission_tags widget_tweaks %} + +{% block content %} + +
+
+
+ {% csrf_token %} + +
+ + + + {% trans 'Topic name'%} +
+
+ + + + {% trans 'Topic description'%} +
+ +
+ + +
+
+
+
+ + +{% endblock content %} diff --git a/courses/templates/topic/replicate_topic.html b/courses/templates/topic/replicate_topic.html deleted file mode 100644 index ec591fa..0000000 --- a/courses/templates/topic/replicate_topic.html +++ /dev/null @@ -1,38 +0,0 @@ -{% extends 'subject/index.html' %} - -{% load static i18n permission_tags widget_tweaks %} - -{% block content %} - -
-
-
- {% csrf_token %} - -
- - - - {% trans 'Topic name'%} -
-
- - - - {% trans 'Topic description'%} -
- -
- - -
-
-
-
- - -{% endblock content %} diff --git a/courses/views.py b/courses/views.py index f6bbebe..c507e9c 100644 --- a/courses/views.py +++ b/courses/views.py @@ -1022,8 +1022,8 @@ class ReplicateTopicView (LoginRequiredMixin, HasRoleMixin, LogMixin, Notificati allowed_roles = ['professor', 'system_admin'] login_url = reverse_lazy("core:home") - model = Topic - template_name = 'topic/replicate_topic.html' + redirect_field_name = 'next' + template_name = 'topic/replicate.html' form_class = TopicForm def get_success_url(self): @@ -1032,21 +1032,23 @@ class ReplicateTopicView (LoginRequiredMixin, HasRoleMixin, LogMixin, Notificati def get_context_data(self, **kwargs): context = super(ReplicateTopicView, self).get_context_data(**kwargs) topic = get_object_or_404(Topic, slug = self.kwargs.get('slug')) - subject = topic.subject + subject = Subject.objects.get(pk = topic.subject_id) context['course'] = subject.course context['subject'] = subject context['subjects'] = subject.course.subjects.all() context['topic'] = topic return context - def form_valid(self, form): - self.object.subject = self.object.subject.id + topic = get_object_or_404(Topic, slug = self.kwargs.get('slug')) + subject = Subject.objects.get(pk = topic.subject_id) + self.object = form.save(commit = False) + self.object.topic = topic + self.object.subject = subject self.object.owner = self.request.user self.object.save() - - action = super(ReplicateTopicView, self).createorRetrieveAction("replicate Topic") + action = super(ReplicateTopicView, self).createorRetrieveAction("create Topic") super(ReplicateTopicView, self).createNotification("Topic "+ self.object.name + " was created", resource_name=self.object.name, resource_link= reverse('course:view_topic',args=[self.object.slug]), actor=self.request.user, users = self.object.subject.course.students.all() ) @@ -1065,4 +1067,4 @@ class ReplicateTopicView (LoginRequiredMixin, HasRoleMixin, LogMixin, Notificati super(ReplicateTopicView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) - return super(ReplicateTopicView, self).form_valid(form) + return super(ReplicateTopicView, self).form_valid(form) \ No newline at end of file -- libgit2 0.21.2