{% extends "bee_django_report/base.html" %}
{% load bee_django_report_filter %}

{% block content %}
    {% include 'bee_django_report/logo.html' %}
    {% include 'bee_django_report/nav.html' %}
    {% if messages %}
        {% load bootstrap3 %}
        {% bootstrap_messages messages %}
    {% endif %}
    <div class="text-center"><h3>
        {% if mentor %}【{{ mentor|get_name_detail:False  }}】{% endif %}
        {% if year %}{{ year }}年{% endif %}
        {% if week %}第{{ week }}周{% endif %}
        助教分数
    </h3>
    </div>
    {% if mentor or year or week %}
        <a href="{% url 'bee_django_report:mentor_score_list' 0 %}" class="btn btn-default">查看全部</a>
    {% endif %}
    {% if mentor %}
        <div class="text-right">
            <a class="btn btn-default" href="{% url 'bee_django_report:mentor_score_add' mentor.id %}">添加分数</a>
        </div>
    {% endif %}
    {#    <div>共{{ paginator.count }}个</div>#}
    <table class="table">
        <thead>
        <tr>
            <th></th>
            <th>助教</th>
            <th>时间</th>
            <th>分数</th>
            <th>当周排名</th>

        </tr>
        </thead>
        <tbody>
        {% for score in score_list %}
            <tr>
                <td>{{ score.counter }}</td>
                <td>
                    <a href="{% url 'bee_django_report:mentor_score_list' score.mentor.id %}">{{ score.mentor|get_name_detail:False }}</a>
                </td>
                <td>
                    <a href="{% url 'bee_django_report:mentor_score_list' 0 %}?year={{ score.year }}&week={{ score.week }}">{{ score.year }}
                        年第 {{ score.week }} 周</a></td>
                <td>{{ score.score }}</td>
                <td>{{ score.rank|default:'-' }}</td>
                <td>
                    <a href="{% url 'bee_django_report:mentor_score_update' score.id %}  ">修改</a>
                    <a href="#" id="delete_{{ score.id }}"
                       data-confirm="{% url "bee_django_report:mentor_score_delete" score.id %}"
                       onclick="click_del(this)">删除</a>
                </td>
            </tr>

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