main
parent
22b3305fa0
commit
f417ebcb4a
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class App01Config(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'app01'
|
@ -0,0 +1,64 @@
|
||||
# Generated by Django 3.2.13 on 2022-06-13 12:20
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='AdminInfo',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('username', models.CharField(max_length=32, verbose_name='用户名')),
|
||||
('password', models.CharField(max_length=64, verbose_name='密码')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='CourseInfo',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('course_name', models.CharField(max_length=32, verbose_name='课程名称')),
|
||||
('course_brief', models.CharField(default='无', max_length=128, verbose_name='课程介绍')),
|
||||
('class_hour', models.SmallIntegerField(verbose_name='课时')),
|
||||
('points', models.SmallIntegerField(verbose_name='学分')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Department',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('department_name', models.CharField(max_length=32, verbose_name='学院名')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Select',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app01.courseinfo', verbose_name='课程')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='StuInfo',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('username', models.CharField(max_length=32, unique=True, verbose_name='用户名')),
|
||||
('password', models.CharField(max_length=64, verbose_name='密码')),
|
||||
('name', models.CharField(max_length=32, verbose_name='姓名')),
|
||||
('gender', models.SmallIntegerField(choices=[(1, '男'), (2, '女')], verbose_name='性别')),
|
||||
('course', models.ManyToManyField(through='app01.Select', to='app01.CourseInfo')),
|
||||
('department', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app01.department', verbose_name='学院')),
|
||||
],
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='select',
|
||||
name='student',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app01.stuinfo', verbose_name='学生'),
|
||||
),
|
||||
]
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,39 @@
|
||||
from django.db import models
|
||||
|
||||
|
||||
# Create your models here.
|
||||
class StuInfo(models.Model):
|
||||
username = models.CharField(verbose_name='用户名', max_length=32, unique=True)
|
||||
password = models.CharField(verbose_name='密码', max_length=64)
|
||||
name = models.CharField(verbose_name='姓名', max_length=32)
|
||||
gender_choices = (
|
||||
(1, '男'),
|
||||
(2, '女'),
|
||||
)
|
||||
gender = models.SmallIntegerField(verbose_name='性别', choices=gender_choices)
|
||||
department = models.ForeignKey(verbose_name='学院', to='Department', to_field='id', on_delete=models.CASCADE)
|
||||
course = models.ManyToManyField(to='CourseInfo', through='Select')
|
||||
|
||||
|
||||
class Department(models.Model):
|
||||
department_name = models.CharField(verbose_name='学院名', max_length=32)
|
||||
|
||||
def __str__(self):
|
||||
return self.department_name
|
||||
|
||||
|
||||
class CourseInfo(models.Model):
|
||||
course_name = models.CharField(verbose_name='课程名称', max_length=32)
|
||||
course_brief = models.CharField(verbose_name='课程介绍', max_length=128, default='无')
|
||||
class_hour = models.SmallIntegerField(verbose_name='课时')
|
||||
points = models.SmallIntegerField(verbose_name='学分')
|
||||
|
||||
|
||||
class AdminInfo(models.Model):
|
||||
username = models.CharField(verbose_name='用户名', max_length=32)
|
||||
password = models.CharField(verbose_name='密码', max_length=64)
|
||||
|
||||
|
||||
class Select(models.Model):
|
||||
student = models.ForeignKey(StuInfo, verbose_name='学生', on_delete=models.CASCADE)
|
||||
course = models.ForeignKey(CourseInfo, verbose_name='课程', on_delete=models.CASCADE)
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 434 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 18 KiB |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,24 @@
|
||||
{% extends 'base.html' %}
|
||||
{% block nav_content %}
|
||||
<!-- Collect the nav links, forms, and other content for toggling -->
|
||||
<div class="collapse navbar-collapse navbar-ex1-collapse">
|
||||
<ul class="nav navbar-nav" id="navbar-1">
|
||||
<li id="1"><a href="/manage/homepage">首页</a></li>
|
||||
<li id="2"><a href="/manage/stu/list/" class="href">学生管理</a></li>
|
||||
<li id="3"><a href="/manage/course/list/" class="href">课程管理</a></li>
|
||||
<li id="4"><a href="/manage/select/list/" class="href">选课管理</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">管理员<b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="/">退出</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div><!-- /.navbar-collapse -->
|
||||
{% endblock %}
|
||||
{% block main_content %}
|
||||
|
||||
{% endblock %}
|
@ -0,0 +1,27 @@
|
||||
{% extends 'base_admin.html' %}
|
||||
{% block main_content %}
|
||||
<div class="row">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3>新增课程信息</h3>
|
||||
</div>
|
||||
<div class="panel-body" style="overflow-x: scroll; width:100%;">
|
||||
<form action="#" method="post" novalidate>
|
||||
{% csrf_token %}
|
||||
{% for field in form %} <!--field代表每个字段的input框-->
|
||||
<div class="form-group">
|
||||
<label class='control-label' for="{{ field.id_for_label }}">{{ field.label }}</label>
|
||||
<div>
|
||||
{{ field }}<span style="color: red">{{ field.errors.0 }}</span>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<div class="form-group">
|
||||
<input class="btn btn-primary" type="submit" value="添加">
|
||||
<input type="reset" class="btn btn-default" value="重置">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
@ -0,0 +1,27 @@
|
||||
{% extends 'base_admin.html' %}
|
||||
{% block main_content %}
|
||||
<div class="row">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3>修改课程信息</h3>
|
||||
</div>
|
||||
<div class="panel-body" style="overflow-x: scroll; width:100%;">
|
||||
<form action="#" method="post">
|
||||
{% csrf_token %}
|
||||
{% for field in form %} <!--field代表每个字段的input框-->
|
||||
<div class="form-group">
|
||||
<label class='control-label' for="{{ field.id_for_label }}">{{ field.label }}</label>
|
||||
<div>
|
||||
{{ field }}<span class="errors">{{ field.errors.0 }}</span>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<div class="form-group">
|
||||
<input class="btn btn-primary" type="submit" value="修改">
|
||||
<input type="reset" class="btn btn-default" value="重置">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
@ -0,0 +1,68 @@
|
||||
{% 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 %}
|
@ -0,0 +1,8 @@
|
||||
{% extends 'base.html' %}
|
||||
{% block main_content %}
|
||||
<div class="jumbotron">
|
||||
<h1>欢迎使用</h1>
|
||||
<h1>信息管理系统</h1>
|
||||
<p align="right"><a class="btn btn-lg btn-success" href="/login/" role="button">登录</a></p>
|
||||
</div>
|
||||
{% endblock %}
|
@ -0,0 +1,13 @@
|
||||
{% extends 'base_admin.html' %}
|
||||
|
||||
{% block main_content %}
|
||||
<div class="jumbotron">
|
||||
<h1>信息管理系统</h1>
|
||||
<h1>管理员页面</h1>
|
||||
<p align="right">
|
||||
<a class="btn btn-lg btn-success" href="/manage/stu/list/" role="button">学生管理</a>
|
||||
<a class="btn btn-lg btn-success" href="/manage/course/list/" role="button">课程管理</a>
|
||||
<a class="btn btn-lg btn-success" href="#" role="button">选课管理</a>
|
||||
</p>
|
||||
</div>
|
||||
{% endblock %}
|
@ -0,0 +1,46 @@
|
||||
{% extends 'base.html' %}
|
||||
{% block main_content %}
|
||||
<div class="row">
|
||||
<div class="col-md-6 col-md-offset-3">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4>人员登录</h4>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<form action="#" class="form-horizontal" method="post">
|
||||
{% csrf_token %}
|
||||
<div class="col-md-10 col-md-offset-1">
|
||||
<div class="form-group">
|
||||
<label for="role" class="col-md-2">角 色</label>
|
||||
<div class="col-md-10">
|
||||
<select name="role" id="role" class="form-control">
|
||||
<option value="0">学生</option>
|
||||
<option value="1">管理员</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="username" class="col-md-2">用户名</label>
|
||||
<div class="col-md-10">
|
||||
<input type="text" class="form-control" name="username" id="username">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="pwd" class="col-md-2">密 码</label>
|
||||
<div class="col-md-10">
|
||||
<input type="password" class="form-control" name="pwd" id="pwd">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-md-10 col-md-offset-2">
|
||||
<input class="btn btn-primary" type="submit" value="登录">
|
||||
<input type="reset" class="btn btn-default" value="重置">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
@ -0,0 +1,76 @@
|
||||
{% 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 %}
|
@ -0,0 +1,27 @@
|
||||
{% extends 'base_admin.html' %}
|
||||
{% block main_content %}
|
||||
<div class="row">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3>新增学生信息</h3>
|
||||
</div>
|
||||
<div class="panel-body" style="overflow-x: scroll; width:100%;">
|
||||
<form action="#" method="post">
|
||||
{% csrf_token %}
|
||||
{% for field in form %} <!--field代表每个字段的input框-->
|
||||
<div class="form-group">
|
||||
<label class='control-label' for="{{ field.id_for_label }}">{{ field.label }}</label>
|
||||
<div>
|
||||
{{ field }}<span class="errors">{{ field.errors.0 }}</span>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<div class="form-group">
|
||||
<input class="btn btn-primary" type="submit" value="添加">
|
||||
<input type="reset" class="btn btn-default" value="重置">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
@ -0,0 +1,27 @@
|
||||
{% extends 'base_admin.html' %}
|
||||
{% block main_content %}
|
||||
<div class="row">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3>修改学生信息</h3>
|
||||
</div>
|
||||
<div class="panel-body" style="overflow-x: scroll; width:100%;">
|
||||
<form action="#" method="post">
|
||||
{% csrf_token %}
|
||||
{% for field in form %} <!--field代表每个字段的input框-->
|
||||
<div class="form-group">
|
||||
<label class='control-label' for="{{ field.id_for_label }}">{{ field.label }}</label>
|
||||
<div>
|
||||
{{ field }}<span class="errors">{{ field.errors.0 }}</span>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<div class="form-group">
|
||||
<input class="btn btn-primary" type="submit" value="修改">
|
||||
<input type="reset" class="btn btn-default" value="重置">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
@ -0,0 +1,43 @@
|
||||
{% extends 'base.html' %}
|
||||
{% block nav_content %}
|
||||
<!-- Collect the nav links, forms, and other content for toggling -->
|
||||
<div class="collapse navbar-collapse navbar-ex1-collapse">
|
||||
<ul class="nav navbar-nav" id="navbar-1">
|
||||
<li id="0"><a href="/stu/index/{{ sid }}/" class="href">选课页面</a></li>
|
||||
<li id="1"><a href="/stu/selected/{{ sid }}/" class="href">已选课程</a></li>
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">学生<b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="/">退出</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div><!-- /.navbar-collapse -->
|
||||
{% endblock %}
|
||||
{% block main_content %}
|
||||
<div class="row">
|
||||
{% for course in courses %}
|
||||
<div class="col-md-4 col-sm-6">
|
||||
<div class="thumbnail">
|
||||
<img style="height: 200px; width: 100%; display: block;"
|
||||
src="/static/img/{{ course.course_name }}.jpg">
|
||||
<div class="caption">
|
||||
<h3>{{ course.course_name }}</h3>
|
||||
<p>{{ course.class_hour }}学时 {{ course.points }}学分</p>
|
||||
<p>{{ course.course_brief }}</p>
|
||||
<form action="#" method="post">
|
||||
{% csrf_token %}
|
||||
<div class="form-group">
|
||||
<input name='sid' type="text" value="{{ sid }}" hidden>
|
||||
<input name="cid" type='text' value="{{ course.id }}" hidden>
|
||||
<input class="btn btn-primary" type="submit" value="选课">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endblock %}
|
@ -0,0 +1,70 @@
|
||||
{% 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 %}
|
@ -0,0 +1,44 @@
|
||||
{% extends 'base.html' %}
|
||||
{% block nav_content %}
|
||||
<!-- Collect the nav links, forms, and other content for toggling -->
|
||||
<div class="collapse navbar-collapse navbar-ex1-collapse">
|
||||
<ul class="nav navbar-nav" id="navbar-1">
|
||||
<li id="0"><a href="/stu/index/{{ sid }}/" class="href">选课页面</a></li>
|
||||
<li id="1"><a href="/stu/selected/{{ sid }}/" class="href">已选课程</a></li>
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">学生<b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="/">退出</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div><!-- /.navbar-collapse -->
|
||||
{% endblock %}
|
||||
{% block main_content %}
|
||||
<div class="row">
|
||||
{% for course in courses %}
|
||||
<div class="col-md-4 col-sm-6">
|
||||
<div class="thumbnail">
|
||||
<img style="height: 200px; width: 100%; display: block;"
|
||||
src="/static/img/{{ course.course_name }}.jpg">
|
||||
<div class="caption">
|
||||
<h3>{{ course.course_name }}</h3>
|
||||
<p>{{ course.class_hour }}学时 {{ course.points }}学分</p>
|
||||
<p>{{ course.course_brief }}</p>
|
||||
{# 新增退课#}
|
||||
<form action="#" method="post">
|
||||
{% csrf_token %}
|
||||
<div class="form-group">
|
||||
<input type="text" name="sid" value="{{ sid }}" hidden>
|
||||
<input type="text" name="cid" value="{{ course.id }}" hidden>
|
||||
<input type="submit" class="btn btn-primary" value="退选">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endblock %}
|
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
Binary file not shown.
@ -0,0 +1 @@
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,16 @@
|
||||
"""
|
||||
ASGI config for djangoProject project.
|
||||
|
||||
It exposes the ASGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.asgi import get_asgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'djangoProject.settings')
|
||||
|
||||
application = get_asgi_application()
|
@ -0,0 +1,135 @@
|
||||
"""
|
||||
Django settings for djangoProject project.
|
||||
|
||||
Generated by 'django-admin startproject' using Django 3.2.13.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/3.2/topics/settings/
|
||||
|
||||
For the full list of settings and their values, see
|
||||
https://docs.djangoproject.com/en/3.2/ref/settings/
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = 'django-insecure-flnkk=dk$pn_fnnc1!jum1#z+gs$9rgxff&bc40cqkagnghnk-'
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = []
|
||||
|
||||
# Application definition
|
||||
# 新增app就要安装应用
|
||||
INSTALLED_APPS = [
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'app01.apps.App01Config' # 注册了App01这个应用
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'djangoProject.urls'
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
'django.template.context_processors.debug',
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
WSGI_APPLICATION = 'djangoProject.wsgi.application'
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
|
||||
# sqlite3数据库连接设置
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': BASE_DIR / 'db.sqlite3',
|
||||
'CONN_MAX_AGE': 100,
|
||||
}
|
||||
}
|
||||
# MySQL数据库连接设置
|
||||
# DATABASES = {
|
||||
# 'default': {
|
||||
# 'ENGINE': 'django.db.backends.mysql',
|
||||
# 'NAME':'django_prj',
|
||||
# 'USER': 'root',
|
||||
# 'PASSWORD': 'root',
|
||||
# 'HOST': 'localhost',
|
||||
# 'PORT': '3306',
|
||||
# }
|
||||
# }
|
||||
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
|
||||
|
||||
AUTH_PASSWORD_VALIDATORS = [
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
||||
},
|
||||
]
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/3.2/topics/i18n/
|
||||
|
||||
# LANGUAGE_CODE = 'en-us'
|
||||
# 设置为汉语
|
||||
LANGUAGE_CODE = 'zh-hans'
|
||||
|
||||
TIME_ZONE = 'UTC'
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
USE_L10N = True
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/3.2/howto/static-files/
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
|
||||
# Default primary key field type
|
||||
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
@ -0,0 +1,16 @@
|
||||
"""
|
||||
WSGI config for djangoProject project.
|
||||
|
||||
It exposes the WSGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'djangoProject.settings')
|
||||
|
||||
application = get_wsgi_application()
|
@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python
|
||||
"""Django's command-line utility for administrative tasks."""
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
"""Run administrative tasks."""
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'djangoProject.settings')
|
||||
try:
|
||||
from django.core.management import execute_from_command_line
|
||||
except ImportError as exc:
|
||||
raise ImportError(
|
||||
"Couldn't import Django. Are you sure it's installed and "
|
||||
"available on your PYTHONPATH environment variable? Did you "
|
||||
"forget to activate a virtual environment?"
|
||||
) from exc
|
||||
execute_from_command_line(sys.argv)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in new issue