Commit 5a07737c43209ee09a1755f374d0e96e394c54a1
1 parent
cf1eb2cd
Exists in
master
and in
5 other branches
puting de modal delete in remove category
Showing
5 changed files
with
54 additions
and
66 deletions
Show diff stats
courses/templates/category/delete.html
1 | -{% extends 'base.html' %} | |
2 | - | |
3 | -{% load static i18n %} | |
4 | 1 | {% load static i18n permission_tags %} |
5 | 2 | |
6 | -{% block breadcrumbs %} | |
7 | - <ol class="breadcrumb"> | |
8 | - <li><a href="{% url 'app:index' %}">{% trans 'Home' %}</a></li> | |
9 | - <li class="active">{% trans 'Manage Categories' %}</li> | |
10 | - </ol> | |
11 | -{% endblock %} | |
3 | +<!-- Modal (remember to change the ids!!!) --> | |
4 | +<div class="modal fade" id="category" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> | |
5 | + <div class="modal-dialog" role="document"> | |
6 | + <div class="modal-content"> | |
7 | + <!-- Modal Header --> | |
8 | + <div class="modal-header"> | |
12 | 9 | |
13 | -{% block sidebar %} | |
14 | - <div class="panel panel-primary navigation"> | |
15 | - <div class="panel-heading"> | |
16 | - <h5>{% trans 'Menu' %}</h5> | |
17 | - </div> | |
18 | - <div class="panel-body"> | |
19 | - <ul class="nav nav-pills nav-stacked"> | |
20 | - <li><a href="{% url 'users:profile' %}">{% trans 'Profile' %}</a></li> | |
21 | - <li><a href="{% url 'course:manage' %}">{% trans 'My Courses' %}</a></li> | |
22 | - </ul> | |
23 | - </div> | |
10 | + <h4 class="modal-title" id="myModalLabel">{% trans "Delete Category" %}</h4> | |
11 | + </div> | |
12 | + <!-- Modal Body --> | |
13 | + <div class="modal-body"> | |
14 | + <!-- Put ONLY your content here!!! --> | |
15 | + <form id="delete_form" action="" method="post"> | |
16 | + {% csrf_token %} | |
17 | + <p>{% trans 'Are you sure you want to delete the subject' %} "{{category.name}}"?</p> | |
18 | + </form> | |
19 | + </div> | |
20 | + <!-- Modal Footer --> | |
21 | + <div class="modal-footer"> | |
22 | + <!-- Don't remove that!!! --> | |
23 | + <button type="button" class="btn btn-danger btn-raised" data-dismiss="modal">{% trans "Close" %}</button> | |
24 | + <button type="submit" id="button" form="delete_form" class="btn btn-primary btn-raised">{% trans "Delete" %}</button> | |
25 | + <script> | |
26 | + $("#delete_form").submit(function(event) { | |
27 | + Submite.remove("{% url 'course:delete_cat' category.slug %}",$(this).serialize(),"#category_{{category.slug}}"); | |
28 | + event.preventDefault(); | |
29 | + }); | |
30 | + </script> | |
31 | + </div> | |
24 | 32 | </div> |
25 | - | |
26 | -{% if user|has_role:'professor' or user|has_role:'system_admin' %} | |
27 | - | |
28 | - <div class="panel panel-primary navigation"> | |
29 | - <div class="panel-heading"> | |
30 | - <h3 class="panel-title">Actions</h3> | |
31 | - </div> | |
32 | - <div class="panel-body"> | |
33 | - <ul class="nav nav-pills nav-stacked"> | |
34 | - <li><a href="javascript:void(0)">Replicate Course</a></li> | |
35 | - <li><a href="{% url 'course:create' %}">Create Course</a></li> | |
36 | - <li><a href="{% url 'course:create_cat' %}">Create Category</a></li> | |
37 | - </ul> | |
38 | - </div> | |
39 | - </div> | |
40 | - <div class="panel panel-primary navigation"> | |
41 | - <div class="panel-heading"> | |
42 | - <h3 class="panel-title">Category</h3> | |
43 | - </div> | |
44 | - <div class="panel-body"> | |
45 | - <ul class="nav nav-pills nav-stacked"> | |
46 | - <li><a href="{% url 'course:create_cat' %}">Create Category</a></li> | |
47 | - <li><a href="{% url 'course:manage_cat' %}">List Category</a></li> | |
48 | - </ul> | |
49 | - </div> | |
50 | - </div> | |
51 | -{% endif %} | |
52 | -{% endblock %} | |
53 | - | |
54 | -{% block content %} | |
55 | - <div class="card card-content"> | |
56 | - <div class="card-body"> | |
57 | - <form action="" method="post">{% csrf_token %} | |
58 | - <h1>{% trans 'Are you sure you want to delete the category' %} "{{ object }}"?</h1> | |
59 | - <input type="submit" class="btn btn-success btn-sm" value="{% trans 'Yes' %}" /> | |
60 | - <a href="{% url 'course:manage_cat' %}" class="btn btn-danger btn-sm">{% trans 'No' %}</a> | |
61 | - </form> | |
62 | - </div> | |
63 | - </div> | |
64 | -{% endblock %} | |
33 | + </div> | |
34 | +</div> | |
35 | +<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> | |
36 | +<script src="{% static 'js/modal_category.js' %}"></script> | ... | ... |
courses/templates/category/index.html
... | ... | @@ -82,7 +82,8 @@ |
82 | 82 | <td class="text-center"> |
83 | 83 | <a href="{% url 'course:view_cat' category.slug %}" class="btn btn-info btn-sm"><span class="glyphicon glyphicon-eye-open"></span></a> |
84 | 84 | <a href="{% url 'course:update_cat' category.slug %}" class="btn btn-primary btn-sm"><span class="glyphicon glyphicon-edit"></span></a> |
85 | - <a href="{% url 'course:delete_cat' category.slug %}" class="btn btn-danger btn-sm"><span class="glyphicon glyphicon-trash"></span></a> | |
85 | + <a href="javascript:modal.get('{% url 'course:delete_cat' category.slug %}','#category','#modal_category');" class="btn btn-danger btn-sm"><span class="glyphicon glyphicon-trash"></span></a> | |
86 | + | |
86 | 87 | </td> |
87 | 88 | </tr> |
88 | 89 | {% endfor %} |
... | ... | @@ -96,4 +97,6 @@ |
96 | 97 | </tbody> |
97 | 98 | </table> |
98 | 99 | </div> |
99 | -{% endblock %} | |
100 | + <div class="row" id="modal_category"> | |
101 | +<script src="{% static 'js/modal_category.js' %}"></script> | |
102 | +{% endblock %} | |
100 | 103 | \ No newline at end of file | ... | ... |
courses/templates/course/index.html
... | ... | @@ -98,13 +98,13 @@ |
98 | 98 | <div class="panel panel-info"> |
99 | 99 | <div class="panel-heading" role="tab"> |
100 | 100 | <div class="row"> |
101 | - <div class="col-xs-9 col-md-9 titleTopic"> | |
101 | + <div class="col-xs-9 col-md-10 titleTopic"> | |
102 | 102 | <a role="button" data-toggle="collapse" data-parent="#accordion" href=".collapseOne" aria-expanded="false" aria-controls="collapseOne" class="collapsed"> |
103 | 103 | <h4 style="color:white">{{course.name}}</h4> |
104 | 104 | </a> |
105 | 105 | </div> |
106 | 106 | {% if user|has_role:'professor' or user|has_role:'system_admin' %} |
107 | - <div class="col-xs-4 col-md-3" id="divMoreActions"> | |
107 | + <div class="col-xs-4 col-md-2" id="divMoreActions"> | |
108 | 108 | <div class="btn-group"> |
109 | 109 | <button class="btn btn-default btn-sm dropdown-toggle" type="button" id="moreActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> |
110 | 110 | <i class="fa fa-ellipsis-v fa-2x" aria-hidden="true"></i> | ... | ... |
courses/templates/subject/index.html
... | ... | @@ -36,12 +36,12 @@ |
36 | 36 | <div class="panel panel-info"> |
37 | 37 | <div class="panel-heading"> |
38 | 38 | <div class="row"> |
39 | - <div class="col-md-10 col-sm-9"> | |
39 | + <div class="col-md-10 col-sm-10"> | |
40 | 40 | <h3>{{subject}}</h3> |
41 | 41 | </div> |
42 | 42 | {% professor_subject subject user as subject_professor%} |
43 | 43 | {% if subject_professor %} |
44 | - <div class="col-xs-4 col-md-3 divMoreActions"> | |
44 | + <div class="col-xs-4 col-md-2 divMoreActions"> | |
45 | 45 | <div class="btn-group"> |
46 | 46 | <button class="btn btn-default btn-sm dropdown-toggle" type="button" id="moreActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> |
47 | 47 | <i class="fa fa-ellipsis-v fa-2x" aria-hidden="true"></i> | ... | ... |
courses/views.py
... | ... | @@ -305,6 +305,19 @@ class DeleteCatView(LoginRequiredMixin, HasRoleMixin, generic.DeleteView): |
305 | 305 | model = CourseCategory |
306 | 306 | template_name = 'category/delete.html' |
307 | 307 | |
308 | + def dispatch(self, *args, **kwargs): | |
309 | + category = get_object_or_404(CourseCategory, slug = self.kwargs.get('slug')) | |
310 | + if(not has_object_permission('delete_category', self.request.user, category)): | |
311 | + return self.handle_no_permission() | |
312 | + return super(DeleteCatView, self).dispatch(*args, **kwargs) | |
313 | + | |
314 | + | |
315 | + def get_context_data(self, **kwargs): | |
316 | + context = super(DeleteCatView, self).get_context_data(**kwargs) | |
317 | + context['course'] = self.object.course_category | |
318 | + context['category'] = self.object | |
319 | + return context | |
320 | + | |
308 | 321 | def get_success_url(self): |
309 | 322 | messages.success(self.request, _('Category deleted successfully!')) |
310 | 323 | return reverse_lazy('course:manage_cat') | ... | ... |