{% 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' %}
    <h3>考试级别详情</h3>
    <a href="{% url 'bee_django_exam:grade_update'  grade.id %}">修改</a>
    <table class="table">
        <tr>
            <td class="col-xs-3">名称</td>
            <td>{{ grade.name }}</td>
        </tr>
        <tr>
            <td>顺序</td>
            <td>{{ grade.order_by|default:"-" }}</td>
        </tr>
        <tr>
            <td>是否显示</td>
            <td>{{ grade.get_show_text }}</td>
        </tr>
        <tr>
            <td>小图标</td>
            <td>{% if grade.icon.url %}
                <img src="{{ grade.icon.url }}" alt="" style="height: 50px;">
            {% endif %}</td>
        </tr>
        <tr>
            <td>
                <div>证书</div>
                <div>
                    <a href="{{ grade.cert_image.url }}" target="_blank">预览证书原始图片</a>
                </div>
            </td>
            <td>
                <div>
                    <a href="{% url 'bee_django_exam:grade_cert_field_add' grade.id %}">添加证书显示文字</a>
                    <a href="{% url 'bee_django_exam:grade_cert_modify' grade.id %}" target="_blank">预览添加文字后证书</a>
                </div>
                <table class="table">
                    {% for cert_field in grade.gradecertfield_set.all %}
                        <tr>

                            <td>
                                {{ cert_field.name }}
                            </td>
                            <td><a href="{% url 'bee_django_exam:grade_cert_field_update'  cert_field.id %}">修改</a>
                                <a href="#" id="delete_{{ cert_field.id }}"
                                   data-confirm="{% url "bee_django_exam:grade_cert_field_delete" cert_field.id %}"
                                   onclick="click_del(this)">删除</a>
                            </td>

                        </tr>
                    {% endfor %}
                </table>
            </td>
        </tr>

    </table>


    {% if grade.notice %}
        <hr>
        <h3>须知</h3>
        {#        <a href="{% url 'bee_django_exam:notice_update' grade.notice.id %}">修改须知</a>#}
        <hr>
        {{ grade.notice.context|safe|default:"" }}
    {% endif %}
{% 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 %}