{% extends "bee_django_course/base.html" %}
{% load bee_django_course_filter %}
{% block content %}
    <div class="text-center"><h3>
        课程列表
    </h3>
    </div>
    <div class="text-right">
        <a class="btn btn-default" href="{% url 'bee_django_course:course_add' %}">添加课程</a>
    </div>
    <div>共{{ paginator.count }}个</div>
    <table class="table">
        <thead>
        <tr>
            <th>序号</th>
            <th>配图</th>
            <th>名称</th>
            <th>副标题</th>
            <th>显示状态</th>
            <th></th>

        </tr>
        </thead>
        <tbody>
        {% for course in course_list %}
            <tr>
                <td>{{ forloop.counter }}</td>
                <td>
                    {% if course.image %}
                        <img src="{{ course.image.url }}" class="img-thumbnail img-responsive" style="width:100px;"/>
                    {% else %}
                        无
                    {% endif %}
                </td>
                <td>{{ course.name }}</td>
                <td>{{ course.subtitle|default:"" }}</td>
                <td>
                    {% course_status course.status %}
                </td>
                <td>
                    <a href="{% url 'bee_django_course:course_detail' course.id %}  ">详情</a>
                    <a href="{% url 'bee_django_course:course_update' course.id %}  ">修改</a>
{#                    <a href="#" id="delete_{{ course.id }}"#}
{#                       data-confirm="{% url "bee_django_course:course_delete" course.id %}"#}
{#                       onclick="click_del(this)">删除</a>#}
                </td>
            </tr>

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