老师管理
teacher.html
{% extends "base.html" %}
{% block css %}
<style>
.tag{
display: inline-block;
padding: 5px;
border: 1px solid red;
background-color: lightpink;
cursor: pointer;
}
</style>
{% endblock %}
{% block content %}
<h1>老师列表</h1>
<div>
<a href="/add_teacher.html">添加</a>
</div>
<table border="1">
<thead></thead>
<tbody>
{% for dic in teacher_list.values %}
<tr>
<td>{{ dic.nid }}</td>
<td>{{ dic.name }}</td>
<td>
{% for c in dic.cls_list %}
<span class="tag" nid="{{ c.id }}">{{ c.caption }}</span>
{% endfor %}
</td>
<td>
<a href="/edit_teacher-{{ dic.nid }}.html">编辑</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}
{% block js %}
<script>
$(function () {
$('#menu_teacher').addClass('active');
})
</script>
{% endblock %}
add_teacher.html
{% extends "base.html" %}
{% block css %}
{% endblock %}
{% block content %}
<h1>添加老师</h1>
<form action="/add_teacher.html" method="POST">
<p>
老师姓名:<input name="name" type="text" />
</p>
<p>
班级:
<select name="cls" multiple>
{% for row in cls_list %}
<option value="{{ row.id }}">{{ row.caption }}</option>
{% endfor %}
</select>
</p>
<input type="submit" value="提交" />
</form>
{% endblock %}
{% block js %}
<script>
$(function () {
$('#menu_teacher').addClass('active');
})
</script>
{% endblock %}
edit_teacher.html
{% extends "base.html" %}
{% block css %}
{% endblock %}
{% block content %}
<h1>编辑老师</h1>
<form action="/edit_teacher-{{ obj.id }}.html" method="POST">
<input style="display: none" type="text" id="nid" value="{{ obj.id }}" />
<p>
老师姓名:<input name="name" type="text" value="{{ obj.name }}" />
</p>
<p>
已管理班级
<select id="sel" name="cls" multiple>
{% for row in obj_cls_list %}
<option value="{{ row.0 }}">{{ row.1 }}</option>
{% endfor %}
</select>
未管理班级:
<select id="none" multiple>
{% for row in cls_list %}
<option value="{{ row.id }}">{{ row.caption }}</option>
{% endfor %}
</select>
</p>
<div>
<a id="removeCls"> >> </a>
<a id="addCls"> << </a>
</div>
<input id="submit_form" type="submit" value="提交" />
</form>
{% endblock %}
{% block js %}
<script>
$(function () {
$('#menu_teacher').addClass('active');
bindRemoveCls();
bindAddCls();