Commit 077ed1d235405114fa0cb4f23c384e542f37121b

Authored by Jailson Dias
1 parent 146cafb5

ajustes nos templates de category

courses/static/js/modal_category.js
1   -
2 1 var Submite = {
3 2 remove: function(url,dados,id_li_link){
4 3 $('#category').modal('hide');
5 4 $.post(url,dados, function(data){
6 5 $(id_li_link).remove();
7   - $("#modal_category").empty();
8   - $("#accordion").remove();
  6 + $("#modal_remove_cat").empty();
  7 + $(id_li_link).remove();
9 8 $(".modal-backdrop.in").remove();
10 9 alertify.success("Category removed successfully!");
11 10 }).fail(function(){
12   - $("#modal_category").empty();
13   - $("#modal_category").append(data);
  11 + $("#modal_remove_cat").empty();
  12 + $("#modal_remove_cat").append(data);
14 13 $('#category').modal('show');
15 14 });
16 15 }
... ...
courses/templates/category/create.html
... ... @@ -11,13 +11,20 @@
11 11 {% endblock %}
12 12  
13 13 {% block content %}
  14 +{% if messages %}
  15 + {% for message in messages %}
  16 + <script type="text/javascript">
  17 + alertify.success('{{message}}');
  18 + </script>
  19 + {% endfor %}
  20 +{% endif %}
14 21 <div class="card card-content">
15 22 <div class="card-body">
16 23 <form method="post" action="">{% csrf_token %}
17 24 {% for field in form %}
18 25 <div class="form-group {% if form.has_error %}has-error{% endif %}">
19 26 <label for="{{ field.auto_id }}">{{ field.label }}</label>
20   - {% render_field field class='form-control input-sm' %}
  27 + {% render_field field class='form-control' %}
21 28 </div>
22 29 {% if field.errors%}
23 30 <div class="alert alert-danger alert-dismissible" role="alert">
... ...
courses/templates/category/delete.html
1 1 {% load static i18n permission_tags %}
2 2  
3 3 <!-- Modal (remember to change the ids!!!) -->
4   -<div class="modal fade" id="course" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  4 +<script src="{% static 'js/modal_category.js' %}"></script>
  5 +<div class="modal fade" id="category" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
5 6 <div class="modal-dialog" role="document">
6 7 <div class="modal-content">
7 8 <!-- Modal Header -->
... ... @@ -24,7 +25,7 @@
24 25 <button type="submit" id="button" form="delete_form" class="btn btn-primary btn-raised">{% trans "Delete" %}</button>
25 26 <script>
26 27 $("#delete_form").submit(function(event) {
27   - Subimite.remove("{% url 'course:delete_cat' category.slug %}",$(this).serialize(),"#category_{{category.slug}}");
  28 + Submite.remove("{% url 'course:delete_cat' category.slug %}",$(this).serialize(),"#category_{{category.slug}}");
28 29 event.preventDefault();
29 30 });
30 31 </script>
... ...
courses/templates/category/index.html
1 1 {% extends 'home.html' %}
2 2  
3   -{% load static i18n %}
4 3 {% load static i18n permission_tags django_bootstrap_breadcrumbs %}
5 4 {% load widget_tweaks %}
6 5  
7 6 {% block breadcrumbs %}
8 7  
9   - {{ block.super }}
10   - {% breadcrumb 'Manage Categories' 'course:manage_cat' %}
  8 +{{ block.super }}
  9 +{% breadcrumb 'Manage Categories' 'course:manage_cat' %}
11 10  
12 11 {% endblock %}
13 12  
  13 +{# {% block javascript %}#}
  14 + {# <script src="{% static 'js/modals_requisitions.js' %}"></script>#}
  15 +{# {% endblock %}#}
  16 +
14 17 {% block content %}
15   - {% if messages %}
16   - {% for message in messages %}
17   - <div class="alert alert-success alert-dismissible" role="alert">
18   - <button type="button" class="close" data-dismiss="alert" aria-label="Close">
19   - <span aria-hidden="true">&times;</span>
20   - </button>
21   - <p>{{ message }}</p>
22   - </div>
23   - {% endfor %}
24   - {% endif %}
25   - {% if categories|length > 0 %}
26   - {% for category in categories %}
27   - <div class="panel-group ui-accordion ui-widget ui-helper-reset ui-sortable" id="accordion" role="tablist" aria-multiselectable="false">
28   - <div class="group">
29   - <div class="panel panel-info">
30   - <div class="panel-heading" role="tab">
31   - <div class="row">
32   - <div class="col-xs-9 col-md-11 titleTopic">
33   - <h4 style="color:white; margin-left: 20px;">{{category}}</h4>
34   - </div>
35   - <div class="col-xs-4 col-md-1" id="divMoreActions">
36   - <div class="btn-group">
37   - <button class="btn btn-default btn-sm dropdown-toggle" type="button" id="moreActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
38   - <i class="fa fa-ellipsis-v fa-2x" aria-hidden="true"></i>
39   - </button>
40   - <ul class="dropdown-menu pull-right" aria-labelledby="moreActions">
41   - <li><a href="{% url 'course:update_cat' category.slug %}"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i>{% trans 'Update' %}</a></li>
42   - <li><a href="javascript:modal.get('{% url 'course:delete_cat' category.slug %}','#category','#modal_category');"><i class="fa fa-trash fa-fw" aria-hidden="true"></i>{% trans 'Remover' %}</a></li>
43   - </ul>
44   - </div>
45   - </div>
  18 +<script src="{% static 'js/modals_requisitions.js' %}"></script>
  19 + {% if messages %}
  20 + {% for message in messages %}
  21 + <script type="text/javascript">
  22 + alertify.success('{{message}}');
  23 + </script>
  24 + {% endfor %}
  25 + {% endif %}
  26 + {% if categories|length > 0 %}
  27 + {% for category in categories %}
  28 + <div class="panel-group ui-accordion ui-widget ui-helper-reset ui-sortable" id="category_{{category.slug}}" role="tablist" aria-multiselectable="false">
  29 + <div class="group">
  30 + <div class="panel panel-info">
  31 + <div class="panel-heading" role="tab">
  32 + <div class="row">
  33 + <div class="col-xs-9 col-md-11 titleTopic">
  34 + <h4 style="color:white; margin-left: 20px;">{{category}}</h4>
  35 + </div>
  36 + <div class="col-xs-4 col-md-1" id="divMoreActions">
  37 + <div class="btn-group">
  38 + <button class="btn btn-default btn-sm dropdown-toggle" type="button" id="moreActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  39 + <i class="fa fa-ellipsis-v fa-2x" aria-hidden="true"></i>
  40 + </button>
  41 + <ul class="dropdown-menu pull-right" aria-labelledby="moreActions">
  42 + <li><a href="{% url 'course:update_cat' category.slug %}"><i class="fa fa-files-o fa-fw" aria-hidden="true"></i>{% trans 'Update' %}</a></li>
  43 + <li><a href="javascript:modal.get('{% url 'course:delete_cat' category.slug %}','#category','#modal_remove_cat');"><i class="fa fa-trash fa-fw" aria-hidden="true"></i>{% trans 'Remover' %}</a></li>
  44 + </ul>
  45 + </div>
  46 + </div>
  47 + </div>
  48 + </div>
  49 + </div>
  50 + </div>
  51 + </div>
  52 + {% endfor %}
  53 + {% endif %}
  54 + <div id="modal_remove_cat">
46 55  
47   - </div>
48   - </div>
49   - </div>
50   - </div>
51   - </div>
52   - {% endfor %}
53   - {% endif %}
54   - <div class="col-md-12">
55   - <nav aria-label="Page navigation">
56   - <ul class="pagination">
57   - {% if page_obj.has_previous %}
58   - <li>
59   - <a href="?page={{ page_obj.previous_page_number }}"><span><<</span></a>
60   - </li>
61   - {% endif %}
62   - {% for page_number in paginator.page_range %}
63   - <li{% if page_obj.number == page_number %} class="active"{% endif %}>
64   - <a href="?page={{ page_number }}">{{ page_number }}</a>
65   - </li>
66   - {% endfor %}
67   - {% if page_obj.has_next %}
68   - <li>
69   - <a href="?page={{ page_obj.next_page_number }}"><span>>></span></a>
70   - </li>
71   - {% endif %}
72   - </ul>
73   - </nav>
74   - </div>
75   - <div class="row" id="modal_category">
76   -<script src="{% static 'js/modal_category.js' %}"></script>
  56 + </div>
77 57 {% endblock %}
... ...
courses/templates/category/update.html
... ... @@ -14,12 +14,9 @@
14 14 {% block content %}
15 15 {% if messages %}
16 16 {% for message in messages %}
17   - <div class="alert alert-success alert-dismissible" role="alert">
18   - <button type="button" class="close" data-dismiss="alert" aria-label="Close">
19   - <span aria-hidden="true">&times;</span>
20   - </button>
21   - <p>{{ message }}</p>
22   - </div>
  17 + <script type="text/javascript">
  18 + alertify.success('{{message}}');
  19 + </script>
23 20 {% endfor %}
24 21 {% endif %}
25 22 <div class="card card-content">
... ... @@ -29,7 +26,7 @@
29 26 {% for field in form %}
30 27 <div class="form-group {% if form.has_error %}has-error{% endif %}">
31 28 <label for="{{ field.auto_id }}">{{ field.label }}</label>
32   - {% render_field field class='form-control input-sm' %}
  29 + {% render_field field class='form-control' %}
33 30 </div>
34 31 {% if field.errors.length > 0 %}
35 32 <div class="alert alert-danger alert-dismissible" role="alert">
... ...
courses/views.py
... ... @@ -452,7 +452,6 @@ class IndexCatView(LoginRequiredMixin, generic.ListView):
452 452 queryset = CourseCategory.objects.all().order_by("name")
453 453 template_name = 'category/index.html'
454 454 context_object_name = 'categories'
455   - paginate_by = 10
456 455  
457 456 def get_context_data (self, **kwargs):
458 457 context = super(IndexCatView, self).get_context_data(**kwargs)
... ...