{% extends "bee_django_wiki/base.html" %}
{% block content %}
    {% include 'bee_django_wiki/logo.html' %}
    {% include 'bee_django_wiki/nav.html' %}
    <div class="text-center"><h4>分类列表</h4></div>
    {% if perms.bee_django_wiki.add_classify %}
        <div class="text-right">
            <a href="{% url 'bee_django_wiki:classify_add' %}" class="btn btn-default">添加分类</a>
        </div>
    {% endif %}
    <table class="table">
        <thead>
        <tr>
            <th>类目</th>
            <th></th>
        </tr>
        </thead>
        <tbody>
        {% for classify in classify_list %}
            <tr>
                <td>{{ classify.name }}</td>
                <td>
                    {% if perms.bee_django_wiki.change_classify %}
                        <a href="{% url 'bee_django_wiki:classify_update' classify.id %} " class="btn btn-default">修改</a>
                    {% endif %}
                    {% if perms.bee_django_wiki.delete_classify %}
                        <a href="#" id="delete_{{ user.id }}"
                       data-confirm="{% url "bee_django_wiki:classify_delete" classify.id %}"
                       onclick="click_del(this)" class="btn btn-danger">删除</a>
                    {% endif %}
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
    {% include 'bee_django_wiki/paginator.html' %}
{% endblock %}
{% block scripts %}
    <script>
        function click_del(_this) {
            if (!confirm('确认要执行这个操作？')) {
                return false;
            }
            var url = $(_this).attr('data-confirm');
            $.post(url).done(function (data) {
                alert('删除成功!');
                location.reload();
            });
        }
    </script>
{% endblock %}