Commit 72a5bee71becd1125207387ba3166ecb94664e6c
Exists in
master
and in
5 other branches
Merge branch 'dev' of https://github.com/amadeusproject/amadeuslms into dev
Showing
4 changed files
with
46 additions
and
68 deletions
Show diff stats
courses/templates/subject/form_view_teacher.html
... | ... | @@ -25,7 +25,7 @@ |
25 | 25 | <ul class="dropdown-menu pull-right" aria-labelledby="moreActions"> |
26 | 26 | <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> |
27 | 27 | <li><a href="javascript:show_editation('{{topic.slug}}')"><i class="fa fa-pencil fa-fw" aria-hidden="true"></i> {% trans "Edit" %}</a></li> |
28 | - <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> | |
28 | + <li><a href="{% url 'course:delete_topic' topic.slug %}"><i class="fa fa-trash fa-fw" aria-hidden="true"></i> {% trans "Remove" %}</a></li> | |
29 | 29 | </ul> |
30 | 30 | |
31 | 31 | ... | ... |
courses/templates/topic/delete.html
... | ... | @@ -7,14 +7,14 @@ |
7 | 7 | <!-- Modal Header --> |
8 | 8 | <div class="modal-header"> |
9 | 9 | |
10 | - <h4 class="modal-title" id="{{topic.slug}}_delete">{% trans "Delete Course" %}</h4> | |
10 | + <h4 class="modal-title" id="{{topic.slug}}_delete">{% trans "Delete Topic" %}</h4> | |
11 | 11 | </div> |
12 | 12 | <!-- Modal Body --> |
13 | 13 | <div class="modal-body"> |
14 | 14 | <!-- Put ONLY your content here!!! --> |
15 | 15 | <form id="delete_topic_{{topic.slug}}" action="" method="post"> |
16 | 16 | {% csrf_token %} |
17 | - <p>{% trans 'Are you sure you want to delete the subject' %} "{{subject.name}}"?</p> | |
17 | + <p>{% trans 'Are you sure you want to delete the topic' %} "{{topic.name}}"?</p> | |
18 | 18 | </form> |
19 | 19 | </div> |
20 | 20 | <!-- Modal Footer --> |
... | ... | @@ -22,12 +22,6 @@ |
22 | 22 | <!-- Don't remove that!!! --> |
23 | 23 | <button type="button" class="btn btn-default btn-raised" data-dismiss="modal">{% trans "Close" %}</button> |
24 | 24 | <button type="submit" id="button" form="delete_topic_{{topic.slug}}" class="btn btn-primary btn-raised">{% trans "Delete" %}</button> |
25 | - <script> | |
26 | - $("#delete_topic_{{topic.slug}}").submit(function(event) { | |
27 | - RemoveCourse.remove("{% url 'course:delete_subject' subject.slug %}",$(this).serialize(),"#subject_{{subject.slug}}"); | |
28 | - event.preventDefault(); | |
29 | - }); | |
30 | - </script> | |
31 | 25 | </div> |
32 | 26 | </div> |
33 | 27 | </div> | ... | ... |
courses/templates/topic/index.html
... | ... | @@ -38,9 +38,7 @@ |
38 | 38 | <li> |
39 | 39 | <a href="{% url 'course:update_subject' subject.slug %}" data-toggle="modal" data-target="#editSubject"><i class="fa fa-pencil fa-fw" aria-hidden="true"></i> {% trans "Edit" %}</a> |
40 | 40 | </li> |
41 | - <li> | |
42 | - <a href="{% url 'course:delete_subject' subject.slug %}" data-toggle="modal" data-target="#removeSubject"><i class="fa fa-trash fa-fw" aria-hidden="true"></i> {% trans "Remove" %}</a> | |
43 | - </li> | |
41 | + <li><a href="{% url 'course:delete_topic' topic.slug %}"><i class="fa fa-trash fa-fw" aria-hidden="true"></i> {% trans "Remove" %}</a></li> | |
44 | 42 | </ul> |
45 | 43 | </div> |
46 | 44 | {% endif %} |
... | ... | @@ -56,56 +54,6 @@ |
56 | 54 | <div class="panel panel-default"> |
57 | 55 | <div class="panel-body"> |
58 | 56 | {% include "topic/topic_card.html" %} |
59 | - {% comment %} | |
60 | - | |
61 | - | |
62 | - <!--{% for activit in activitys %} | |
63 | - <form class="form-horizontal" enctype='multipart/form-data'>{% csrf_token %} | |
64 | - <fieldset> | |
65 | - <legend>{{activit.name}}</legend> | |
66 | - | |
67 | - | |
68 | - {% for student in students_activit %} | |
69 | - <div class="panel-group" id="accordion"> | |
70 | - <div class="panel panel-info"> | |
71 | - <div class="panel-heading"> | |
72 | - <h4 class="panel-title"> | |
73 | - <a data-toggle="collapse" data-parent="#accordion" href="#collapse1"> | |
74 | - {{student.name}} <i class="fa fa-plus-square" aria-hidden="true"></i></a> | |
75 | - </h4> | |
76 | - </div> | |
77 | - <div id="collapse1" class="panel-collapse collapse"> | |
78 | - <div class="panel-body"> | |
79 | - <div class="row"> | |
80 | - <div class="col-md-4"> | |
81 | - <i class="fa fa-file-archive-o fa-lg" aria-hidden="true">{% trans 'Atividade.doc' %}</i> | |
82 | - </div> | |
83 | - {% professor_subject subject user as permi_test%} | |
84 | - {% if permi_test %} | |
85 | - <div class="col-md-4"> | |
86 | - <label> {% trans 'Grade' %}:</label> | |
87 | - <input type="number" step="0.01"> | |
88 | - </div> | |
89 | - {% else %} | |
90 | - <div class="col-md-4"> | |
91 | - <input type="hidden" name="id" value=""> | |
92 | - <input type="hidden" name="student" value=""> | |
93 | - <div class="form-group {% if form.pdf.errors %} has-error {% endif %}"> | |
94 | - {{ form.as_p }} | |
95 | - </div> | |
96 | - <button type="submit" class="btn btn-success" id="send_button">{% trans 'Send' %}</button> | |
97 | - </div> | |
98 | - {% endif %} | |
99 | - </div> | |
100 | - </div> | |
101 | - </div> | |
102 | - </div> | |
103 | - </div> | |
104 | - {% endfor %} | |
105 | - </div> | |
106 | - </fieldset> | |
107 | - </form>--> | |
108 | -{% endcomment %} | |
109 | 57 | </div> |
110 | 58 | </div> |
111 | 59 | </div> | ... | ... |
courses/views.py
... | ... | @@ -388,19 +388,55 @@ class CourseView(LogMixin, NotificationMixin, generic.DetailView): |
388 | 388 | |
389 | 389 | return context |
390 | 390 | |
391 | -class DeleteTopic(LoginRequiredMixin, HasRoleMixin, NotificationMixin, generic.DeleteView): | |
391 | +class DeleteTopic(LoginRequiredMixin, HasRoleMixin, LogMixin, generic.DeleteView): | |
392 | + log_component = "course" | |
393 | + log_resource = "topic" | |
394 | + log_action = "delete" | |
395 | + log_context = {} | |
392 | 396 | |
393 | 397 | allowed_roles = ['professor', 'system_admin'] |
394 | 398 | login_url = reverse_lazy("core:home") |
395 | 399 | redirect_field_name = 'next' |
396 | 400 | model = Topic |
397 | - template_name = 'course/delete.html' | |
398 | - success_url = reverse_lazy('course:manage') | |
401 | + template_name = 'topic/delete.html' | |
402 | + | |
403 | + def dispatch(self, *args, **kwargs): | |
404 | + topic = get_object_or_404(Topic, slug = self.kwargs.get('slug')) | |
405 | + if(not has_object_permission('delete_topic', self.request.user, topic)): | |
406 | + return self.handle_no_permission() | |
407 | + return super(DeleteTopic, self).dispatch(*args, **kwargs) | |
408 | + | |
409 | + def get_context_data(self, **kwargs): | |
410 | + context = super(DeleteTopic, self).get_context_data(**kwargs) | |
411 | + context['course'] = self.object.subject.course | |
412 | + context['subject'] = self.object.subject | |
413 | + context['topic'] = self.object | |
414 | + if (has_role(self.request.user,'system_admin')): | |
415 | + context['subjects'] = self.object.subject.course.subjects.all() | |
416 | + else: | |
417 | + context['subjects'] = self.object.subject.course.subjects.filter(Q(visible=True) | Q(professors__in=[self.request.user])) | |
418 | + | |
419 | + return context | |
399 | 420 | |
400 | - def render_to_response(self, context, **response_kwargs): | |
401 | - messages.success(self.request, _('Course deleted successfully!')) | |
421 | + def get_success_url(self): | |
422 | + self.log_context['topic_id'] = self.object.id | |
423 | + self.log_context['topic_name'] = self.object.name | |
424 | + self.log_context['topic_slug'] = self.object.slug | |
425 | + | |
426 | + self.log_context['subject_id'] = self.object.subject.id | |
427 | + self.log_context['subject_name'] = self.object.subject.name | |
428 | + self.log_context['subject_slug'] = self.object.subject.slug | |
429 | + | |
430 | + self.log_context['course_id'] = self.object.subject.course.id | |
431 | + self.log_context['course_name'] = self.object.subject.course.name | |
432 | + self.log_context['course_slug'] = self.object.subject.course.slug | |
433 | + self.log_context['course_category_id'] = self.object.subject.course.category.id | |
434 | + self.log_context['course_category_name'] = self.object.subject.course.category.name | |
435 | + | |
436 | + super(DeleteTopic, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | |
437 | + | |
438 | + return reverse_lazy('course:view_subject', kwargs={'slug' : self.object.subject.slug}) | |
402 | 439 | |
403 | - return self.response_class(request=self.request, template=self.get_template_names(), context=context, using=self.template_engine) | |
404 | 440 | |
405 | 441 | |
406 | 442 | @login_required | ... | ... |