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

{% block content %}
    {% include 'bee_django_exam/logo.html' %}
    {% include 'bee_django_exam/nav.html' %}
    <div class="text-center"><h3>
        学生考级列表
    </h3>
    </div>

    <table class="table">
        <thead>
        <tr>
            <th>学生姓名</th>
            <th>申请时间</th>
            <th>考级级别</th>
            <th>状态</th>
            <th></th>

        </tr>
        </thead>
        <tbody>
        {% for record in record_list %}
            <tr>
                <td>{{ record.user|get_record_user_name }}
                    {#                    {% if record.user.id|get_icon %}#}
                    {#                        <img src="{{ record.user.id|get_icon }}" alt="" style="height: 20px;">#}
                    {#                    {% endif %}#}
                </td>
                <td>{{ record.created_at|local_datetime|date:"Y-m-d H:i" }}</td>
                <td>{{ record.grade_name }}</td>
                <td>{{ record.get_status_text }}
                    {% if record.status == 1 %}
                        {% if record.cert %}
                            <a href="{{ record.cert }}" target="_blank">证书图片</a>

                        {% endif %}
                        <button class="btn btn-success"
                                data-confirm="{% url "bee_django_exam:user_cert_create" record.id %}"
                                onclick="click_create_cert(this)">生成证书
                        </button>
                    {% endif %}</td>
                <td>
                    <a href="{% url 'bee_django_exam:user_exam_record_detail' record.id %}"
                       class="btn btn-default">详情</a>
                    <a href="{% url 'bee_django_exam:user_exam_record_update' record.id %}"
                       class="btn btn-default">操作</a>

                </td>

            </tr>

        {% endfor %}
        </tbody>
    </table>
    {% include 'bee_django_exam/paginator.html' %}
{% endblock %}
{% block scripts %}
    <script>
        function click_create_cert(_this) {
            var url = $(_this).attr('data-confirm');
            $.post(url).done(function (data) {
                alert(data.msg);
                if (data.res) {
                    location.reload();
                }
            });
        }

    </script>
{% endblock %}