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. <div class="table-responsive">
  32. {% with bulk_edit_url=content_type.model_class|validated_viewname:"bulk_edit" bulk_delete_url=content_type.model_class|validated_viewname:"bulk_delete" %}
  33. {% if permissions.change or permissions.delete %}
  34. <form method="post" class="form form-horizontal">
  35. {% csrf_token %}
  36. <input type="hidden" name="return_url" value="{% if return_url %}{{ return_url }}{% else %}{{ request.path }}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}{% endif %}" />
  37. {% if table.paginator.num_pages > 1 %}
  38. <div id="select_all_box" class="hidden panel panel-default noprint">
  39. <div class="panel-body">
  40. <div class="checkbox-inline">
  41. <label for="select_all">
  42. <input type="checkbox" id="select_all" name="_all" />
  43. Select <strong>all {{ table.rows|length }} {{ table.data.verbose_name_plural }}</strong> matching query
  44. </label>
  45. </div>
  46. <div class="pull-right">
  47. {% if bulk_edit_url and permissions.change %}
  48. <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">
  49. <span class="mdi mdi-pencil" aria-hidden="true"></span> Edit All
  50. </button>
  51. {% endif %}
  52. {% if bulk_delete_url and permissions.delete %}
  53. <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">
  54. <span class="mdi mdi-trash-can-outline" aria-hidden="true"></span> Delete All
  55. </button>
  56. {% endif %}
  57. </div>
  58. </div>
  59. </div>
  60. {% endif %}
  61. {% render_table table 'inc/table.html' %}
  62. <div class="pull-left noprint">
  63. {% block bulk_buttons %}{% endblock %}
  64. {% if bulk_edit_url and permissions.change %}
  65. <button type="submit" name="_edit" formaction="{% url bulk_edit_url %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-warning btn-sm">
  66. <span class="mdi mdi-pencil" aria-hidden="true"></span> Edit Selected
  67. </button>
  68. {% endif %}
  69. {% if bulk_delete_url and permissions.delete %}
  70. <button type="submit" name="_delete" formaction="{% url bulk_delete_url %}{% if request.GET %}?{{ request.GET.urlencode }}{% endif %}" class="btn btn-danger btn-sm">
  71. <span class="mdi mdi-trash-can-outline" aria-hidden="true"></span> Delete Selected
  72. </button>
  73. {% endif %}
  74. </div>
  75. </form>
  76. {% else %}
  77. {% render_table table 'inc/table.html' %}
  78. {% endif %}
  79. {% endwith %}
  80. </div>
  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 %}