{% extends "bee_django_course/base.html" %}
{% load bee_django_course_filter %}
{% block content %}
    <div class="text-center">
        <h3>
            {% if user %}{{ user|get_name_detail:False }}的{% endif %}{{ title_str|default:'' }}录播列表
        </h3>
    </div>
    {% if search_form %}
        {% include 'bee_django_course/live/user_live_search.html' %}
    {% endif %}
    <div style="margin: 10px 0;">共{{ paginator.count }}个</div>
    <div><span class="glyphicon glyphicon-star" style="color: red"></span>：标星录播</div>
    <div><span class="glyphicon glyphicon-certificate" style="color: purple"></span>：认证录播</div>
    <table class="table">
        <thead>
        <tr>
            <th></th>
            <th></th>
            <th></th>
            <th></th>
            <th>学生</th>
            <th>video ID|live ID</th>
            <th>开始时间</th>
            <th>时长</th>
            <th>助教是否看过</th>
            <th></th>
            <th></th>
        </tr>
        </thead>
        <tbody>
        {% for live in live_list %}
            <tr>
                <td>{% if live.coin_multiple >= 2 %}
                    <span style="color: red"> ({{ live.coin_multiple }}倍{{ context_coin_name }}) </span>
                {% endif %}
                </td>
                <td>{{ forloop.counter }}</td>
                <td>
                    {% if live.is_star %}
                    <span class="glyphicon glyphicon-star" style="color: red"></span>
                {% endif %}
                    {% if live.is_certify %}
                    <span class="glyphicon glyphicon-certificate" style="color: purple"></span>
                {% endif %}
                </td>
                <td>{{ live.provider_name }}</td>
                <td><a href="{{ live.user.get_user_search_link }}">{{ live.user }}</a></td>
                <td>{{ live.record_video_id|default:"" }} |<br>{{ live.live_id|default:"" }}</td>
                <td>{{ live.start_time|date:"Y-m-d H:i:s" }}</td>
                <td>{{ live.get_duration_str }}</td>

                <td>
                    {% if live.is_mentor_view %}
                        √
                    {% endif %}
                </td>
                <td>
                    {% if live.record_status == '10' %}
                        <a href="{% url 'bee_django_course:live_video_detail' user_live_id=live.id %}">
                            查看
                            {% if live.get_mentor_comments_status %}
                                (已点评)
                            {% endif %}
                        </a>
                    {% elif live.record_status == '20' %}
                        录制失败
                    {% elif live.record_status == '30' %}
                        视频过长
                    {% else %}
                        转码中
                    {% endif %}
                </td>
                <td>
                    {% if perms.bee_django_course.delete_userlive and live.status == 1 %}
                        <a href="#" class="hide-user-live btn btn-danger"
                           data-confirm="{% url 'bee_django_course:hide_user_live' user_live_id=live.id %}">
                            删除
                        </a>
                    {% endif %}
                    {% if perms.bee_django_course.delete_userlive and live.status == -1 %}
                        <a href="#" class="recover-user-live btn btn-info"
                           data-confirm="{% url 'bee_django_course:recover_user_live' user_live_id=live.id %}">
                            恢复
                        </a>
                    {% endif %}
                </td>
            </tr>

        {% endfor %}
        </tbody>
    </table>
    {% include 'bee_django_course/paginator.html' %}
{% endblock %}
{% block scripts %}
    <script type="text/javascript">
        $(document).ready(function () {
            $('#id_user_name').attr("autocomplete", "off");
            $(".hide-user-live").click(function (e) {
                e.preventDefault();
                var url = $(this).attr('data-confirm');
                _this_tr = $(this).parent().parent();

                if (confirm('同时也会删除此记录对应的M币 是否继续？')) {
                    $.post(url).done(function (data) {
                        alert("操作成功");
                        {#_this_tr.remove();#}
                        location.reload();
                    });
                }
            });
            $(".recover-user-live").click(function (e) {
                e.preventDefault();
                var url = $(this).attr('data-confirm');
                _this_tr = $(this).parent().parent();

                if (confirm('同时也会恢复此记录对应的M币 是否继续？')) {
                    $.post(url).done(function (data) {
                        alert("操作成功");
                        {#_this_tr.remove();#}
                        location.reload();
                    });
                }
            });
        });
    </script>
{% endblock %}