{% extends 'base_admin.html' %}

{% block main_content %}
    <div class="row">
        <div class="panel panel-default">
            <div class="panel-heading">
                <form action="#" class="form-inline">
                    <input type="text" class="form-control" name="key" id="key" placeholder="按课程查找">
                    <input type="submit" class="btn btn-default" value="搜索">
                </form>
            </div>
            <div class="panel-body" style="overflow-x: scroll; width:100%;">
                <a href="/manage/course/add/" class="btn btn-success" style="margin-bottom: 10px">新增课程</a>
                <table class="table table-hover" style="width:150%; height:100px; text-align:left" >
                    <tr>
                        <th>#</th>
                        <th>课程名称</th>
                        <th>课程简介</th>
                        <th>课时</th>
                        <th>学分</th>
                        <th>操作</th>
                    </tr>
                    {% for course in courses %}
                        <tr>
                            <td>{{ forloop.counter }}</td>
                            <td>{{ course.course_name }}</td>
                            <td>{{ course.course_brief }}</td>
                            <td>{{ course.class_hour }}</td>
                            <td>{{ course.points }}</td>

                            <td>
                                <a href="/manage/course/edit/{{ course.id }}/" class="btn btn-default btn-xs" title="编辑"><i class="fa fa-edit"></i>编辑</a>
                                <a href="/manage/course/del/{{ course.id }}/" class="btn btn-default btn-xs" title="删除"><i class="fa fa-trash"></i>删除</a>
                            </td>
                        </tr>
                    {% endfor %}
                </table>
                <nav aria-label="Page navigation">
            <ul class="pagination">
                {% if courses.has_previous %}
                    <li class="prev-page"><a href="?page={{ courses.previous_page_number }}">上一页</a></li>
                {% else %}
                    <li class="prev-page"></li>
                {% endif %}

                {% for num in courses.paginator.page_range %}
                    {% if num %}
                        {% ifequal num courses.number %}
                            <li class="active"><span>{{ num }}</span></li>
                        {% else %}
                            <li><a href="?page={{ num }}">{{ num }}</a></li>
                        {% endifequal %}
                    {% else %}
                        <li class="disabled"><span>...</span></li>
                    {% endif %}
                {% endfor %}

                {% if courses.has_next %}
                    <li class="next-page"><a href="?page={{ courses.next_page_number }}">下一页</a></li>
                {% else %}
                    <li class="next-page"></li>
                {% endif %}
            </ul>
        </nav>
            </div>
        </div>
    </div>
{% endblock %}