object_list.html 5.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. {% extends 'base.html' %}
  2. {% load buttons %}
  3. {% load helpers %}
  4. {% load render_table from django_tables2 %}
  5. {% load static %}
  6. {% block content %}
  7. <div class="pull-right noprint">
  8. {% block buttons %}{% endblock %}
  9. {% if request.user.is_authenticated and table_config_form %}
  10. <button type="button" class="btn btn-default" data-toggle="modal" data-target="#ObjectTable_config" title="Configure table"><i class="mdi mdi-cog"></i> Configure</button>
  11. {% endif %}
  12. {% if permissions.add and 'add' in action_buttons %}
  13. {% add_button content_type.model_class|validated_viewname:"add" %}
  14. {% endif %}
  15. {% if permissions.add and 'import' in action_buttons %}
  16. {% import_button content_type.model_class|validated_viewname:"import" %}
  17. {% endif %}
  18. {% if 'export' in action_buttons %}
  19. {% export_button content_type %}
  20. {% endif %}
  21. </div>
  22. <h1>{% block title %}{{ content_type.model_class|meta:"verbose_name_plural"|bettertitle }}{% endblock %}</h1>
  23. <div class="row">
  24. <div class="col-md-12">
  25. {% if filter_form %}
  26. <div class="col-md-3 pull-right right-side-panel noprint">
  27. {% include 'inc/search_panel.html' %}
  28. {% block sidebar %}{% endblock %}
  29. </div>
  30. {% endif %}
  31. {% with bulk_edit_url=content_type.model_class|validated_viewname:"bulk_edit" bulk_delete_url=content_type.model_class|validated_viewname:"bulk_delete" %}
  32. {% if permissions.change or permissions.delete %}
  33. <form method="post" class="form form-horizontal">
  34. {% csrf_token %}
  35. <input type="hidden" name="return_url" value="{% if return_url %}{{ return_url }}{% else %}{{ request.path }}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}{% endif %}" />
  36. {% if table.paginator.num_pages > 1 %}
  37. <div id="select_all_box" class="hidden panel panel-default noprint">
  38. <div class="panel-body">
  39. <div class="checkbox-inline">
  40. <label for="select_all">
  41. <input type="checkbox" id="select_all" name="_all" />
  42. Select <strong>all {{ table.rows|length }} {{ table.data.verbose_name_plural }}</strong> matching query
  43. </label>
  44. </div>
  45. <div class="pull-right">
  46. {% if bulk_edit_url and permissions.change %}
  47. <button type="submit" name="_edit" formaction="{% url bulk_edit_url %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-warning btn-sm" disabled="disabled">
  48. <span class="mdi mdi-pencil" aria-hidden="true"></span> Edit All
  49. </button>
  50. {% endif %}
  51. {% if bulk_delete_url and permissions.delete %}
  52. <button type="submit" name="_delete" formaction="{% url bulk_delete_url %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-danger btn-sm" disabled="disabled">
  53. <span class="mdi mdi-trash-can-outline" aria-hidden="true"></span> Delete All
  54. </button>
  55. {% endif %}
  56. </div>
  57. </div>
  58. </div>
  59. {% endif %}
  60. <div class="table-responsive">
  61. {% render_table table 'inc/table.html' %}
  62. </div>
  63. <div class="pull-left noprint">
  64. {% block bulk_buttons %}{% endblock %}
  65. {% if bulk_edit_url and permissions.change %}
  66. <button type="submit" name="_edit" formaction="{% url bulk_edit_url %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-warning btn-sm">
  67. <span class="mdi mdi-pencil" aria-hidden="true"></span> Edit Selected
  68. </button>
  69. {% endif %}
  70. {% if bulk_delete_url and permissions.delete %}
  71. <button type="submit" name="_delete" formaction="{% url bulk_delete_url %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-danger btn-sm">
  72. <span class="mdi mdi-trash-can-outline" aria-hidden="true"></span> Delete Selected
  73. </button>
  74. {% endif %}
  75. </div>
  76. </form>
  77. {% else %}
  78. {% render_table table 'inc/table.html' %}
  79. {% endif %}
  80. {% endwith %}
  81. {% include 'inc/paginator.html' with paginator=table.paginator page=table.page %}
  82. <div class="clearfix"></div>
  83. </div>
  84. </div>
  85. {% table_config_form table table_name="ObjectTable" %}
  86. {% endblock %}
  87. {% block javascript %}
  88. <script src="{% static 'js/tableconfig.js' %}"></script>
  89. {% endblock %}