Commit e71c793fdda1c82f2ff4ff595c5f35ced1ed7d18
1 parent
707b27ef
Exists in
master
and in
5 other branches
[Issue #399]
Showing
4 changed files
with
49 additions
and
47 deletions
Show diff stats
courses/templates/subject/form_view_teacher.html
... | ... | @@ -21,7 +21,7 @@ |
21 | 21 | {% professor_subject topic.subject user as dropdown_topic %} |
22 | 22 | {% if dropdown_topic %} |
23 | 23 | <ul class="dropdown-menu pull-right" aria-labelledby="moreActions"> |
24 | - <li><a href="" data-toggle="modal" data-target="#myModal4"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i> {% trans "Replicate" %}</a></li> | |
24 | + <li><a href="{% url 'course:replicate_topic' topic.slug %}"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i> {% trans "Replicate" %}</a></li> | |
25 | 25 | <li><a href="javascript:show_editation('{{topic.slug}}')"><i class="fa fa-pencil fa-fw" aria-hidden="true"></i> {% trans "Edit" %}</a></li> |
26 | 26 | <li><a href="javascript:void(0)" data-toggle="modal" data-target="#removeTopic"><i class="fa fa-trash fa-fw" aria-hidden="true"></i> {% trans "Remove" %}</a></li> |
27 | 27 | </ul> | ... | ... |
... | ... | @@ -0,0 +1,38 @@ |
1 | +{% extends 'subject/index.html' %} | |
2 | + | |
3 | +{% load static i18n permission_tags widget_tweaks %} | |
4 | + | |
5 | +{% block content %} | |
6 | + | |
7 | + <div class="panel panel-default"> | |
8 | + <div class="panel-body"> | |
9 | + <form class="form-group " method="post" action=""> | |
10 | + {% csrf_token %} | |
11 | + | |
12 | + <div class="form-group {% if topic.name.errors %} has-error{% endif %}"> | |
13 | + <label for="id_name" class="control-label label-static"> {% trans 'Name'%}</label> | |
14 | + <textarea class="form-control" id="id_name" maxlength="100" rows="1" name="name" placeholder="Name" type="text" required >{{topic.name}}</textarea> | |
15 | + | |
16 | + <span class="help-block">{% trans 'Topic name'%}</span> | |
17 | + </div> | |
18 | + <div class="form-group {% if topic.description.errors %} has-error{% endif %}"> | |
19 | + <label for="id_description" class="control-label label-static"> {% trans 'Description'%}</label> | |
20 | + <textarea class="form-control" id="id_description" name="description" placeholder="Description" type="text"> {{topic.description}}</textarea> | |
21 | + | |
22 | + <span class="help-block">{% trans 'Topic description'%}</span> | |
23 | + </div> | |
24 | + | |
25 | + <div class="col-lg-offset-4 col-lg-4"> | |
26 | + <button type="submit" class="btn btn-raised btn-primary btn-lg btn-block">{% trans 'Create' %}</button> | |
27 | + | |
28 | + </div> | |
29 | + </form> | |
30 | + </div> | |
31 | + </div> | |
32 | + | |
33 | + <script type="text/javascript"> | |
34 | + $(document).ready(function() { | |
35 | + $('#id_description').summernote({height: 300}); | |
36 | + }); | |
37 | + </script> | |
38 | +{% endblock content %} | ... | ... |
courses/templates/topic/replicate_topic.html
... | ... | @@ -1,38 +0,0 @@ |
1 | -{% extends 'subject/index.html' %} | |
2 | - | |
3 | -{% load static i18n permission_tags widget_tweaks %} | |
4 | - | |
5 | -{% block content %} | |
6 | - | |
7 | - <div class="panel panel-default"> | |
8 | - <div class="panel-body"> | |
9 | - <form class="form-group " method="post" action=""> | |
10 | - {% csrf_token %} | |
11 | - | |
12 | - <div class="form-group {% if topic.name.errors %} has-error{% endif %}"> | |
13 | - <label for="id_name" class="control-label label-static"> {% trans 'Name'%}</label> | |
14 | - <input class="form-control" id="id_name" maxlength="100" name="name" placeholder="Name" type="text" value={{topic.name}} required /> | |
15 | - | |
16 | - <span class="help-block">{% trans 'Topic name'%}</span> | |
17 | - </div> | |
18 | - <div class="form-group {% if topic.description.errors %} has-error{% endif %}"> | |
19 | - <label for="id_description" class="control-label label-static"> {% trans 'Description'%}</label> | |
20 | - <textarea class="form-control" id="id_description" name="description" placeholder="Description" type="text"> {{topic.description}}</textarea> | |
21 | - | |
22 | - <span class="help-block">{% trans 'Topic description'%}</span> | |
23 | - </div> | |
24 | - | |
25 | - <div class="col-lg-offset-4 col-lg-4"> | |
26 | - <button type="submit" class="btn btn-raised btn-primary btn-lg btn-block">{% trans 'Create' %}</button> | |
27 | - | |
28 | - </div> | |
29 | - </form> | |
30 | - </div> | |
31 | - </div> | |
32 | - | |
33 | - <script type="text/javascript"> | |
34 | - $(document).ready(function() { | |
35 | - $('#id_description').summernote({height: 300}); | |
36 | - }); | |
37 | - </script> | |
38 | -{% endblock content %} |
courses/views.py
... | ... | @@ -1022,8 +1022,8 @@ class ReplicateTopicView (LoginRequiredMixin, HasRoleMixin, LogMixin, Notificati |
1022 | 1022 | |
1023 | 1023 | allowed_roles = ['professor', 'system_admin'] |
1024 | 1024 | login_url = reverse_lazy("core:home") |
1025 | - model = Topic | |
1026 | - template_name = 'topic/replicate_topic.html' | |
1025 | + redirect_field_name = 'next' | |
1026 | + template_name = 'topic/replicate.html' | |
1027 | 1027 | form_class = TopicForm |
1028 | 1028 | |
1029 | 1029 | def get_success_url(self): |
... | ... | @@ -1032,21 +1032,23 @@ class ReplicateTopicView (LoginRequiredMixin, HasRoleMixin, LogMixin, Notificati |
1032 | 1032 | def get_context_data(self, **kwargs): |
1033 | 1033 | context = super(ReplicateTopicView, self).get_context_data(**kwargs) |
1034 | 1034 | topic = get_object_or_404(Topic, slug = self.kwargs.get('slug')) |
1035 | - subject = topic.subject | |
1035 | + subject = Subject.objects.get(pk = topic.subject_id) | |
1036 | 1036 | context['course'] = subject.course |
1037 | 1037 | context['subject'] = subject |
1038 | 1038 | context['subjects'] = subject.course.subjects.all() |
1039 | 1039 | context['topic'] = topic |
1040 | 1040 | return context |
1041 | 1041 | |
1042 | - | |
1043 | 1042 | def form_valid(self, form): |
1044 | - self.object.subject = self.object.subject.id | |
1043 | + topic = get_object_or_404(Topic, slug = self.kwargs.get('slug')) | |
1044 | + subject = Subject.objects.get(pk = topic.subject_id) | |
1045 | + | |
1045 | 1046 | self.object = form.save(commit = False) |
1047 | + self.object.topic = topic | |
1048 | + self.object.subject = subject | |
1046 | 1049 | self.object.owner = self.request.user |
1047 | 1050 | self.object.save() |
1048 | - | |
1049 | - action = super(ReplicateTopicView, self).createorRetrieveAction("replicate Topic") | |
1051 | + action = super(ReplicateTopicView, self).createorRetrieveAction("create Topic") | |
1050 | 1052 | super(ReplicateTopicView, self).createNotification("Topic "+ self.object.name + " was created", |
1051 | 1053 | resource_name=self.object.name, resource_link= reverse('course:view_topic',args=[self.object.slug]), |
1052 | 1054 | actor=self.request.user, users = self.object.subject.course.students.all() ) |
... | ... | @@ -1065,4 +1067,4 @@ class ReplicateTopicView (LoginRequiredMixin, HasRoleMixin, LogMixin, Notificati |
1065 | 1067 | |
1066 | 1068 | super(ReplicateTopicView, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) |
1067 | 1069 | |
1068 | - return super(ReplicateTopicView, self).form_valid(form) | |
1070 | + return super(ReplicateTopicView, self).form_valid(form) | |
1069 | 1071 | \ No newline at end of file | ... | ... |