{% 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/stu/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>
                        <th>操作</th>
                    </tr>
                    {% for student in students %}
                        <tr>
                            <td>{{ forloop.counter }}</td>
                            <td>{{ student.name }}</td>
                            <td>{{ student.get_gender_display }}</td>
                            <td>{{ student.department.department_name }}</td>
                            <td>{{ student.username }}</td>
                            <td>{{ student.password }}</td>

                            <td>
                                <a href="/manage/stu/edit/{{ student.id }}/" class="btn btn-default btn-xs" title="编辑"><i class="fa fa-edit"></i>编辑</a>
                                <a href="/manage/stu/del/{{ student.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 students.has_previous %}
                    <li class="prev-page"><a href="?page={{ students.previous_page_number }}">上一页</a></li>
                {% else %}
                    <li class="prev-page"></li>
                {% endif %}

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