{% extends "bee_django_exam/base.html" %}
{% load bee_django_crm_filter %}

{% block content %}
    {% include 'bee_django_exam/logo.html' %}
    {% include 'bee_django_exam/nav.html' %}
    <div class="text-center"><h3>
        级别列表
    </h3>
    </div>
    <div class="text-right">
        <a class="btn btn-default" href="{% url 'bee_django_exam:grade_add' %}">添加考试级别</a>
    </div>

    <table class="table">
        <thead>
        <tr>
            <th>顺序</th>
            <th>级别名称</th>
            <th>是否显示</th>
            <th></th>

        </tr>
        </thead>
        <tbody>
        {% for grade in grade_list %}
            <tr>
                <td>{{ grade.order_by }}</td>
                <td>{{ grade.name }}</td>
                <td>{{ grade.get_show_text }}</td>
                <td>
                    <a href="{% url 'bee_django_exam:grade_detail' grade.id %}  ">详情</a>
                    <a href="{% url 'bee_django_exam:grade_update' grade.id %}  ">修改</a>
                    <a href="#" id="delete_{{ grade.id }}"
                       data-confirm="{% url "bee_django_exam:grade_delete" grade.id %}"
                       onclick="click_del(this)">删除</a>
                </td>
            </tr>

        {% endfor %}
        </tbody>
    </table>
    {% include 'bee_django_exam/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 %}