weekend_table.html 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. {% spaceless %}
  2. {% load django_tables2 %}
  3. {% load i18n %}
  4. {% if table.page %}
  5. <div class="table-container">
  6. {% endif %}
  7. {% block table %}
  8. <table{% if table.attrs %} {{ table.attrs.as_html }}{% endif %}>
  9. {% nospaceless %}
  10. {% block table.thead %}
  11. <thead>
  12. <tr>
  13. {% for column in table.columns %}
  14. {% if column.orderable %}
  15. <th {{ column.attrs.th.as_html }}><a href="{% querystring table.prefixed_order_by_field=column.order_by_alias.next %}">{{ column.header }}</a></th>
  16. {% else %}
  17. <th {{ column.attrs.th.as_html }}>{{ column.header }}</th>
  18. {% endif %}
  19. {% endfor %}
  20. </tr>
  21. </thead>
  22. {% endblock table.thead %}
  23. {% block table.tbody %}
  24. <tbody>
  25. {% for row in table.page.object_list|default:table.rows %} {# support pagination #}
  26. {% block table.tbody.row %}
  27. {% if row.date.is_weekend %}
  28. <tr class="weekend"> {# avoid cycle for Django 1.2-1.6 compatibility #}
  29. {% else %}
  30. <tr class="{{ forloop.counter|divisibleby:2|yesno:"even,odd" }}"> {# avoid cycle for Django 1.2-1.6 compatibility #}
  31. {% endif %}
  32. {% for column, cell in row.items %}
  33. <td {{ column.attrs.td.as_html }}>{% if column.localize == None %}{{ cell }}{% else %}{% if column.localize %}{{ cell|localize }}{% else %}{{ cell|unlocalize }}{% endif %}{% endif %}</td>
  34. {% endfor %}
  35. </tr>
  36. {% endblock table.tbody.row %}
  37. {% empty %}
  38. {% if table.empty_text %}
  39. {% block table.tbody.empty_text %}
  40. <tr><td colspan="{{ table.columns|length }}">{{ table.empty_text }}</td></tr>
  41. {% endblock table.tbody.empty_text %}
  42. {% endif %}
  43. {% endfor %}
  44. </tbody>
  45. {% endblock table.tbody %}
  46. {% block table.tfoot %}
  47. <tfoot></tfoot>
  48. {% endblock table.tfoot %}
  49. {% endnospaceless %}
  50. </table>
  51. {% endblock table %}
  52. {% if table.page %}
  53. {% with table.page.paginator.count as total %}
  54. {% with table.page.object_list|length as count %}
  55. {% block pagination %}
  56. <ul class="pagination">
  57. {% if table.page.has_previous %}
  58. {% nospaceless %}{% block pagination.previous %}<li class="previous"><a href="{% querystring table.prefixed_page_field=table.page.previous_page_number %}">{% trans "Previous" %}</a></li>{% endblock pagination.previous %}{% endnospaceless %}
  59. {% endif %}
  60. {% if table.page.has_previous or table.page.has_next %}
  61. {% nospaceless %}{% block pagination.current %}<li class="current">{% blocktrans with table.page.number as current and table.paginator.num_pages as total %}Page {{ current }} of {{ total }}{% endblocktrans %}</li>{% endblock pagination.current %}{% endnospaceless %}
  62. {% endif %}
  63. {% if table.page.has_next %}
  64. {% nospaceless %}{% block pagination.next %}<li class="next"><a href="{% querystring table.prefixed_page_field=table.page.next_page_number %}">{% trans "Next" %}</a></li>{% endblock pagination.next %}{% endnospaceless %}
  65. {% endif %}
  66. {% nospaceless %}{% block pagination.cardinality %}<li class="cardinality">{% if total != count %}{% blocktrans %}{{ count }} of {{ total }}{% endblocktrans %}{% else %}{{ total }}{% endif %} {% if total == 1 %}{{ table.data.verbose_name }}{% else %}{{ table.data.verbose_name_plural }}{% endif %}</li>{% endblock pagination.cardinality %}{% endnospaceless %}
  67. </ul>
  68. {% endblock pagination %}
  69. {% endwith %}
  70. {% endwith %}
  71. </div>
  72. {% endif %}
  73. {% endspaceless %}