{% 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%;">
                <table class="table table-hover" style="width:150%; height:100px; text-align:left">
                    <tr>
                        <th>#</th>
                        <th>课程</th>
                        <th>姓名</th>
                        <th>操作</th>
                    </tr>
                    {#                    {% for k,vs in queryset.items %}#}
                    {#                        {% for v in vs %}#}
                    {#                            <tr>#}
                    {#                                <td>{{ forloop.counter }}</td>#}
                    {#                                <td>{{ v.course_name }}</td>#}
                    {#                                <td>{{ k }}</td>#}
                    {##}
                    {#                                <td>#}
                    {#                                    <a href="/manage/select/del/{{ v.id }}/{{ k }}/" class="btn btn-default btn-xs" title="删除"><i class="fa fa-trash"></i>删除</a>#}
                    {#                                </td>#}
                    {#                            </tr>#}
                    {#                        {% endfor %}#}
                    {#                    {% endfor %}#}
                    {% for select in selects %}
                        <tr>
                            <td>{{ forloop.counter }}</td>
                            <td>{{ select.course.course_name }}</td>
                            <td>{{ select.student.name }}</td>

                            <td>
                                <a href="/manage/select/del/{{ select.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 selects.has_previous %}
                            <li class="prev-page"><a href="?page={{ selects.previous_page_number }}">上一页</a></li>
                        {% else %}
                            <li class="prev-page"></li>
                        {% endif %}

                        {% for num in selects.paginator.page_range %}
                            {% if num %}
                                {% ifequal num selects.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 selects.has_next %}
                            <li class="next-page"><a href="?page={{ selects.next_page_number }}">下一页</a></li>
                        {% else %}
                            <li class="next-page"></li>
                        {% endif %}
                    </ul>
                </nav>
            </div>
        </div>
    </div>
{% endblock %}