Compare commits

...

4 Commits

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6" project-jdk-type="Python SDK" />
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
</project>

@ -14,21 +14,7 @@
</component>
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<<<<<<< Updated upstream
=======
<<<<<<< Updated upstream
>>>>>>> Stashed changes
<<<<<<< HEAD
<orderEntry type="jdk" jdkName="Python 3.8 (2)" jdkType="Python SDK" />
=======
<orderEntry type="jdk" jdkName="Python 3.7 (EduSystemServer)" jdkType="Python SDK" />
>>>>>>> 7b09141c358f80dd8877b8665d0d55b629db72aa
<<<<<<< Updated upstream
=======
=======
<orderEntry type="jdk" jdkName="Python 3.7 (EduSystemServer)" jdkType="Python SDK" />
>>>>>>> Stashed changes
>>>>>>> Stashed changes
<orderEntry type="jdk" jdkName="Python 3.9" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TemplatesService">

@ -1,20 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="edu_sys@localhost" uuid="fc67d607-329d-4381-af5b-a0e372257c56">
<data-source source="LOCAL" name="@localhost" uuid="9660bbaf-5fdd-4aa5-8754-d2dc6487fc96">
<driver-ref>mysql.8</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mysql://localhost:3306/edu_sys</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
<data-source source="LOCAL" name="Django default" uuid="ffb088a0-406e-44b2-aed0-9587474966bf">
<driver-ref>mysql.8</driver-ref>
<synchronize>true</synchronize>
<imported>true</imported>
<remarks>$PROJECT_DIR$/EduSystemServer/settings.py</remarks>
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mysql://127.0.0.1:3306/edu_sys</jdbc-url>
<jdbc-url>jdbc:mysql://localhost:3306</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>

@ -1,18 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<<<<<<< Updated upstream
=======
<<<<<<< Updated upstream
>>>>>>> Stashed changes
<<<<<<< HEAD
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (2)" project-jdk-type="Python SDK" />
=======
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (EduSystemServer)" project-jdk-type="Python SDK" />
>>>>>>> 7b09141c358f80dd8877b8665d0d55b629db72aa
<<<<<<< Updated upstream
=======
=======
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (EduSystemServer)" project-jdk-type="Python SDK" />
>>>>>>> Stashed changes
>>>>>>> Stashed changes
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
</project>

@ -12,9 +12,7 @@ https://docs.djangoproject.com/en/2.2/ref/settings/
import os
<<<<<<< Updated upstream
=======
CORS_ALLOW_ORIGIN_WHITELIST = [
"http://localhost:8080", # 允许访问的来源
"http://localhost:8000", # 允许访问的来源
@ -22,7 +20,7 @@ CORS_ALLOW_ORIGIN_WHITELIST = [
]
CORS_ALLOW_CREDENTIALS = True # 允许跨域请求携带凭据例如Cookies
>>>>>>> Stashed changes
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@ -65,7 +63,7 @@ MIDDLEWARE = [
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'corsheaders.middleware.CorsMiddleware',
<<<<<<< Updated upstream
'django.middleware.common.CommonMiddleware',
# 'API.middle.AuthMiddleware',
]
@ -86,13 +84,6 @@ CORS_ALLOW_HEADERS = (
'Pragma',
)
=======
# 'API.middle.AuthMiddleware',
]
>>>>>>> Stashed changes
ROOT_URLCONF = 'EduSystemServer.urls'
TEMPLATES = [

@ -16,26 +16,14 @@ Including another URLconf
from django.contrib import admin
from django.urls import path, include
from API.views import login, get_user_info
<<<<<<< Updated upstream
=======
>>>>>>> Stashed changes
urlpatterns = [
path('Eduadmin/', admin.site.urls),
path('api/', include(("API.urls", "api"), namespace="api")),
<<<<<<< Updated upstream
=======
<<<<<<< Updated upstream
>>>>>>> Stashed changes
path('api/', include(("API.urls", "API"), namespace="api")),
path('teacher/', include(("teacher.urls", "teacher"), namespace="teacher")),
path('student/', include(("Student.urls", "student"), namespace="student")),
path('student/', include(("Student.urls", "Student"), namespace="student")),
path('course/', include(("course.urls", "course"), namespace="course")),
=======
path('student/', include(("Student.urls", "studnet"), namespace="student")),
>>>>>>> Stashed changes
path('admin/', include(("Eduadmin.urls", "Eduadmin"), namespace="Eduadmin")),
path('login', login),
path('userinfo', get_user_info),
]

@ -7,6 +7,9 @@ class Admin(models.Model):
username = models.CharField(max_length=32, primary_key=True, name="username", verbose_name="管理员账号", blank=True)
password = models.CharField(max_length=128, name="password", verbose_name="管理员密码", blank=True)
def to_dict(self):
return {"username": self.username, "password": self.password}
class Meta:
db_table = "Eduadmin"
verbose_name = "管理员"

@ -1,3 +1,108 @@
from django.shortcuts import render
from django.db.models import Q
# Create your views here.
from teacher.models import Teacher
from Student.models import Student
from course.models import SC, Course
from django.views.decorators.csrf import csrf_exempt
from django.http import QueryDict
from io import BytesIO
from django.http.multipartparser import MultiPartParser
import json
from django.http import JsonResponse
from EduSystemServer.utils import ResponseUtil
from .models import Admin
# 修改个人信息
@csrf_exempt
def admin_info(request):
if request.method == "POST":
try:
admin = Admin()
admin.username = request.POST.get("username")
admin.password = request.POST.get("password")
admin.save()
response = ResponseUtil.ok(admin.to_dict(), "添加成功!")
return JsonResponse(response)
except Exception as E:
return JsonResponse(ResponseUtil.error(E))
elif request.method == "GET":
username = request.GET.get("username")
try:
ad_info = Admin.objects.filter(username=username).values()
data = {
'管理员账号': ad_info[0]['username'],
'管理员密码': ad_info[0]['password']
}
response = ResponseUtil.ok(data, "查询成功!")
return JsonResponse(response)
except Exception as E:
return JsonResponse(ResponseUtil.error(E))
# 学生管理
@csrf_exempt
def student_manage(request):
if request.method == "GET":
student = Student.objects.all().values()
stu_list = []
for i in range(len(student)):
data = {
'学生编号': student[i]['sid'],
'用户账号': student[i]['username'],
'用户密码': student[i]['password'],
'姓名': student[i]['name'],
'性别': student[i]['sex'],
'年级': student[i]['grade'],
'班级': student[i]['class_name'],
'专业': student[i]['major'],
}
stu_list.append(data)
response = ResponseUtil.ok(stu_list, "学生信息查询成功!")
return JsonResponse(response)
elif request.method == "POST":
sid = request.GET.get('sid')
try:
stu_info = Student.objects.get(sid=sid)
username = request.POST.get("username") or stu_info.username
password = request.POST.get("password") or stu_info.password
name = request.POST.get("name") or stu_info.name
sex = request.POST.get("sex") or stu_info.sex
grade = request.POST.get("grade") or stu_info.grade
class_name = request.POST.get("class_name") or stu_info.class_name
major = request.POST.get("major") or stu_info.major
Student.objects.filter(sid=sid).update(username=username, password=password, name=name, sex=sex,
grade=grade, class_name=class_name, major=major)
except Exception as E:
return JsonResponse(ResponseUtil.error(E))
elif request.method == "DELETE":
delete = MultiPartParser(request.META, BytesIO(request.body), request.upload_handlers, request.encoding).parse()
sid = delete[0]['sid']
try:
info = Student.objects.filter(sid=sid).get().to_dict()
Student.objects.filter(sid=sid).delete()
response = ResponseUtil.ok(info, "删除成功!")
return JsonResponse(response)
except:
return JsonResponse(ResponseUtil.error("删除失败,未找到学生信息!"))
elif request.method == "PUT":
put = MultiPartParser(request.META, request, request.upload_handlers, request.encoding).parse()
sid = put[0]['sid']
username = put[0]['username']
name = put[0]['name']
sex = put[0]['sex']
grade = put[0]['grade']
class_name = put[0]['class_name']
major = put[0]['major']
if Student.objects.filter(sid=sid):
Student.objects.filter(sid=sid).update(username=username, name=name, sex=sex, grade=grade,
class_name=class_name,
major=major)
else:
return JsonResponse(ResponseUtil.error("没有查询到该同学!"))
data = Student.objects.filter(sid=sid)[0].to_dict()
return JsonResponse(ResponseUtil.ok(data, "修改成功!"))

@ -12,37 +12,37 @@ class Migration(migrations.Migration):
operations = [
migrations.AlterField(
model_name='student',
name='s_class_name',
name='class_name',
field=models.CharField(blank=True, max_length=50, verbose_name='班级'),
),
migrations.AlterField(
model_name='student',
name='s_grade',
name='grade',
field=models.CharField(blank=True, max_length=20, verbose_name='年级'),
),
migrations.AlterField(
model_name='student',
name='s_major',
name='major',
field=models.CharField(blank=True, max_length=50, verbose_name='专业名称'),
),
migrations.AlterField(
model_name='student',
name='s_name',
name='name',
field=models.CharField(blank=True, max_length=100, verbose_name='姓名'),
),
migrations.AlterField(
model_name='student',
name='s_password',
name='password',
field=models.CharField(blank=True, max_length=100, verbose_name='密码'),
),
migrations.AlterField(
model_name='student',
name='s_sex',
name='sex',
field=models.CharField(blank=True, max_length=4, verbose_name='性别'),
),
migrations.AlterField(
model_name='student',
name='s_username',
name='username',
field=models.CharField(blank=True, max_length=30, verbose_name='用户名称'),
),
migrations.AlterField(

@ -4,38 +4,6 @@ from django.db import models
# Create your models here.
class Student(models.Model):
sid = models.AutoField(primary_key=True, verbose_name="学生编号", name="sid")
<<<<<<< Updated upstream
=======
<<<<<<< Updated upstream
>>>>>>> Stashed changes
<<<<<<< HEAD
s_username = models.CharField(max_length=30, verbose_name="用户名称", name="s_username", blank=True)
s_password = models.CharField(max_length=100, verbose_name="密码", name="s_password", blank=True)
s_name = models.CharField(max_length=100, verbose_name="姓名", name="s_name", blank=True)
s_sex = models.CharField(max_length=4, verbose_name="性别", name="s_sex", blank=True)
s_grade = models.CharField(max_length=20, verbose_name="年级", name="s_grade", blank=True)
s_class_name = models.CharField(max_length=50, verbose_name="班级", name="s_class_name", blank=True)
s_major = models.CharField(max_length=50, verbose_name="专业名称", name="s_major", blank=True)
def to_dict(self):
return {"sid": self.sid, "s_name": self.s_name, "s_username": self.s_username, "s_password": self.s_password,
"s_sex": self.s_sex, "s_grade": self.s_grade, "class_name": self.s_class_name, "s_major": self.s_major}
=======
username = models.CharField(max_length=30, verbose_name="用户名称", name="username", blank=True)
password = models.CharField(max_length=100, verbose_name="密码", name="password", blank=True)
name = models.CharField(max_length=100, verbose_name="姓名", name="name", blank=True)
sex = models.CharField(max_length=4, verbose_name="性别", name="sex", blank=True)
grade = models.CharField(max_length=20, verbose_name="年级", name="grade", blank=True)
class_name = models.CharField(max_length=50, verbose_name="班级", name="class_name", blank=True)
major = models.CharField(max_length=50, verbose_name="专业名称", name="major", blank=True)
def to_dict(self):
return {"sid": self.sid, "name": self.name, "username": self.username, "password": self.password,
"sex": self.sex, "grade": self.grade, "class_name": self.class_name, "major": self.major}
>>>>>>> 7b09141c358f80dd8877b8665d0d55b629db72aa
<<<<<<< Updated upstream
=======
=======
username = models.CharField(max_length=30, verbose_name="用户名称", name="username", blank=True)
password = models.CharField(max_length=100, verbose_name="密码", name="password", blank=True)
name = models.CharField(max_length=100, verbose_name="姓名", name="name", blank=True)
@ -47,9 +15,6 @@ class Student(models.Model):
def to_dict(self):
return {"sid": self.sid, "name": self.name, "username": self.username, "password": self.password,
"sex": self.sex, "grade": self.grade, "class_name": self.class_name, "major": self.major}
>>>>>>> Stashed changes
>>>>>>> Stashed changes
class Meta:
db_table = "student"
verbose_name = "学生"

@ -4,5 +4,9 @@ from .views import *
urlpatterns = [
path("", studnets),
path("selectCourse", get_select_course_by_id)
path("selectCourse", get_select_course_by_id),
path("selectGrade/", search_grade),
path("changeInfo/", change_info),
path("chooseCourse/", choose_course),
path("deleteCourse/",delete_course)
]

@ -1,22 +1,16 @@
from django.shortcuts import render
# Create your views here.
from django.http import HttpRequest
from django.http import JsonResponse
<<<<<<< Updated upstream
from .models import Student
=======
<<<<<<< HEAD
from EduSystemServer.utils import ResponseUtil
from Student.models import Student
=======
from .models import Student
>>>>>>> 1e084d20f30e0b66d5e309a483f87ce5cfe06c39
>>>>>>> Stashed changes
from teacher.models import Teacher
from course.models import SC, Course
from django.views.decorators.csrf import csrf_exempt
from django.http import QueryDict
from io import BytesIO
from django.http.multipartparser import MultiPartParser
import json
@csrf_exempt
@ -34,47 +28,48 @@ def studnets(request):
student.class_name = request_data.get("class_name")
student.major = request_data.get("major")
student.save()
response = ResponseUtil.ok(student.to_dict(), "更新成功!")
response = ResponseUtil.ok(student.to_dict(), "添加成功!")
return JsonResponse(response)
except Exception as E:
return JsonResponse(ResponseUtil.error(E))
elif request.method == "GET":
sid = request.GET.get('sid')
s_name = request.GET.get('s_name')
s_sex = request.GET.get('s_sex')
s_grade = request.GET.get('s_grade')
s_class_name = request.GET.get('s_class_name')
s_major = request.GET.get('s_major')
name = request.GET.get('name')
sex = request.GET.get('sex')
grade = request.GET.get('grade')
class_name = request.GET.get('class_name')
major = request.GET.get('major')
data = []
if sid:
filtered = Student.objects.filter(sid=sid)
for student in filtered:
data.append(student.to_dict())
elif s_name:
filtered = Student.objects.filter(s_name=s_name)
elif name:
filtered = Student.objects.filter(name=name)
for student in filtered:
data.append(student.to_dict())
elif s_sex:
filtered = Student.objects.filter(s_sex=s_sex)
elif sex:
filtered = Student.objects.filter(sex=sex)
for student in filtered:
data.append(student.to_dict())
elif s_grade:
filtered = Student.objects.filter(s_grade=s_grade)
elif grade:
filtered = Student.objects.filter(grade=grade)
for student in filtered:
data.append(student.to_dict())
elif s_class_name:
filtered = Student.objects.filter(s_class_name=s_class_name)
elif class_name:
filtered = Student.objects.filter(class_name=class_name)
for student in filtered:
data.append(student.to_dict())
elif s_major:
filtered = Student.objects.filter(s_major=s_major)
elif major:
filtered = Student.objects.filter(major=major)
for student in filtered:
data.append(student.to_dict())
else:
all_objects = Student.objects.all()
for studnet in all_objects:
data.append(studnet.to_dict())
return JsonResponse({'code': 200, 'msg': 'success', 'data': data}, safe=False)
for student in all_objects:
data.append(student.to_dict())
response = ResponseUtil.ok(data, "查询成功!")
return JsonResponse(response)
elif request.method == "DELETE":
parser = MultiPartParser(request.META, BytesIO(request.body), request.upload_handlers, request.encoding)
post_dict = parser.parse()
@ -82,42 +77,167 @@ def studnets(request):
try:
info = Student.objects.filter(sid=sid).get().to_dict()
Student.objects.filter(sid=sid).delete()
response = {"code": 200, "message": "删除成功!", "data": info}
response = ResponseUtil.ok(info, "删除成功!")
return JsonResponse(response)
except:
response = {"code": 200, "message": "删除失败,未找到学生信息!"}
return JsonResponse(response)
return JsonResponse(ResponseUtil.error("删除失败,未找到学生信息!"))
elif request.method == "PUT":
put = MultiPartParser(request.META, request, request.upload_handlers, request.encoding).parse()
sid = put[0]['sid']
s_username = put[0]['s_username']
s_name = put[0]['s_name']
s_sex = put[0]['s_sex']
s_grade = put[0]['s_grade']
s_class_name = put[0]['s_class_name']
s_major = put[0]['s_major']
username = put[0]['username']
name = put[0]['name']
sex = put[0]['sex']
grade = put[0]['grade']
class_name = put[0]['class_name']
major = put[0]['major']
if Student.objects.filter(sid=sid):
Student.objects.filter(sid=sid).update(username=username, name=name, sex=sex, grade=grade,
class_name=class_name,
major=major)
else:
return JsonResponse(ResponseUtil.error("没有查询到该同学!"))
data = Student.objects.filter(sid=sid)[0].to_dict()
return JsonResponse(ResponseUtil.ok(data, "修改成功!"))
# 查询成绩
def search_grade(request): # 获取SID返回该同学的所有成绩
if request.method == "GET":
sid = request.GET.get('sid')
cid = SC.objects.filter(sid_id=sid).values()
data_list = []
for i in range(len(cid)):
c_name = Course.objects.filter(cid=cid[i]['cid_id']).values('name')[0]['name']
middle_grade = cid[i]['middle_grade']
end_grade = cid[i]['end_grade']
data = {
'c_name': c_name,
'平时成绩': middle_grade,
'最终成绩': end_grade
}
data_list.append(data)
return JsonResponse(ResponseUtil.ok(data_list, "成绩查询成功!"))
# 修改信息
@csrf_exempt
def change_info(request):
if request.method == "GET":
sid = request.GET.get('sid')
info = Student.objects.filter(sid=sid).values()
data = {
'学生编号': sid,
'用户账号': info[0]['username'],
'用户密码': info[0]['password'],
'姓名': info[0]['name'],
'性别': info[0]['sex'],
'年级': info[0]['grade'],
'班级': info[0]['class_name'],
'专业': info[0]['major'],
}
return JsonResponse(ResponseUtil.ok(data, "个人信息查询成功!"))
elif request.method == "POST":
sid = request.GET.get('sid')
stu_info = Student.objects.get(sid=sid)
username = request.POST.get('username') or stu_info.username
password = request.POST.get('password') or stu_info.password
name = request.POST.get('name') or stu_info.name
sex = request.POST.get('sex') or stu_info.sex
grade = request.POST.get('grade') or stu_info.grade
class_name = request.POST.get('class_name') or stu_info.class_name
major = request.POST.get('major') or stu_info.major
Student.objects.filter(sid=sid).update(username=username, password=password, name=name, sex=sex, grade=grade,
class_name=class_name, major=major)
data = {
'学生编号': sid,
'用户账号': username,
'用户密码': password,
'姓名': name,
'性别': sex,
'年级': grade,
'班级': class_name,
'专业': major,
}
return JsonResponse(ResponseUtil.ok(data, "学生信息修改成功!"))
# 选课
@csrf_exempt
def choose_course(request):
if request.method == "GET": # 将所有课程信息返回
course_list = []
course = Course.objects.all().values()
for i in range(len(course)):
teacher = Teacher.objects.filter(tid=course[i]['tid_id']).values('name')
data = {
'课程编号': course[i]['cid'],
'课程名称': course[i]['name'],
'课程类型': course[i]['type'],
'课程学分': course[i]['credit'],
'教师': teacher[0]['name'],
}
course_list.append(data)
return JsonResponse(ResponseUtil.ok(course_list, "课程查询成功!"))
elif request.method == "POST": # 将选择的课程添加到选课表
sid = request.GET.get('sid')
cid = request.POST.get('cid_id')
try:
Student.objects.filter(sid=sid).update(s_username=s_username, s_name=s_name, s_sex=s_sex, s_grade=s_grade,
s_class_name=s_class_name,
s_major=s_major)
SC.objects.create(sid_id=sid, cid_id=cid)
course = Course.objects.filter(cid=cid).values()
teacher = Teacher.objects.filter(tid=course[0]['tid_id']).values('name')
data = {
'课程编号': cid,
'课程名称': course[0]['name'],
'课程类型': course[0]['type'],
'课程学分': course[0]['credit'],
'教师': teacher[0]['name'],
}
return JsonResponse(ResponseUtil.ok(data, "选课成功!"))
except:
Student.objects.create(sid=sid, s_username=s_username, s_name=s_name, s_sex=s_sex, s_grade=s_grade,
s_class_name=s_class_name,
s_major=s_major)
data = Student.objects.filter(sid=sid)[0].to_dict()
return JsonResponse({'code': 200, 'msg': 'success', 'data': data}, safe=False)
student_list = Student.objects.all()
response_json = {"code": 200, "message": "success", "data": []}
for student in student_list:
response_json["data"].append(student.to_dict())
return JsonResponse(response_json)
elif request.method == 'DELETE':
params = QueryDict(request.body)
key = next(iter(params.keys())) # 获取键名
value = params.get(key) # 获取值
xx = str(value).split('-')[0]
print(xx.split('\r\n'))
return JsonResponse({'code': 200, 'msg': 'success'}, safe=False)
return JsonResponse(ResponseUtil.error("选课失败!"))
# 退课
@csrf_exempt
def delete_course(request):
if request.method == "GET": # 返回用户所有选择的课程
sid = request.GET.get('sid')
course_list = []
try:
cid = SC.objects.filter(sid_id=sid).values('cid_id') # 通过选课表找到学生选的所有课程
for i in range(len(cid)):
course = Course.objects.filter(cid=cid[i]['cid_id']).values() # 在课程表中找课程详细信息
teacher = Teacher.objects.filter(tid=course[0]['tid_id']).values('name')
data = {
'课程编号': course[0]['cid'],
'课程名称': course[0]['name'],
'课程类型': course[0]['type'],
'课程学分': course[0]['credit'],
'教师': teacher[0]['name'],
}
course_list.append(data)
return JsonResponse(ResponseUtil.ok(course_list, "课程查询成功!"))
except:
return JsonResponse(ResponseUtil.error('你还没有选课!'))
elif request.method == "POST": # 将用户选择的课程删除
sid = request.GET.get('sid')
cid = request.POST.get('cid')
try:
course = Course.objects.filter(cid=cid).values() # 在课程表中找课程详细信息
teacher = Teacher.objects.filter(tid=course[0]['tid_id']).values('name')
data = {
'课程编号': course[0]['cid'],
'课程名称': course[0]['name'],
'课程类型': course[0]['type'],
'课程学分': course[0]['credit'],
'教师': teacher[0]['name'],
}
SC.objects.filter(sid_id=sid, cid_id=cid).delete()
return JsonResponse(ResponseUtil.ok(data, "退课成功!"))
except:
JsonResponse(ResponseUtil.error('退课失败!'))
def get_select_course_by_id(request):
pass

@ -12,12 +12,12 @@ class Migration(migrations.Migration):
operations = [
migrations.AlterField(
model_name='course',
name='c_name',
name='name',
field=models.CharField(blank=True, max_length=255, verbose_name='课程名称'),
),
migrations.AlterField(
model_name='course',
name='c_type',
name='type',
field=models.CharField(blank=True, max_length=128, verbose_name='课程类型'),
),
]

@ -13,7 +13,7 @@ class Course(models.Model):
tid = models.ForeignKey(Teacher, to_field="tid", on_delete=models.CASCADE, name="tid")
def to_dict(self):
return {"cid": self.cid, "c_name": self.name, "type": self.type, "credit": self.credit,
return {"cid": self.cid, "name": self.name, "type": self.type, "credit": self.credit,
"tid": self.tid}
class Meta:
@ -25,8 +25,8 @@ class Course(models.Model):
class SC(models.Model):
sid = models.ForeignKey(Student, to_field="sid", on_delete=models.CASCADE, name="sid")
cid = models.ForeignKey(Course, to_field="cid", on_delete=models.CASCADE, name="cid")
middle_grade = models.IntegerField(name="middle_grade")
end_grade = models.IntegerField(name="end_grade")
middle_grade = models.IntegerField(name="middle_grade", blank=True, null=True)
end_grade = models.IntegerField(name="end_grade", blank=True, null=True)
def to_dict(self):
return {"sid": self.sid, "cid": self.cid, "middle_grade": self.middle_grade, "end_grade": self.end_grade}

@ -12,27 +12,27 @@ class Migration(migrations.Migration):
operations = [
migrations.AlterField(
model_name='teacher',
name='t_dept',
name='dept',
field=models.CharField(blank=True, max_length=128, verbose_name='教师所属院系'),
),
migrations.AlterField(
model_name='teacher',
name='t_education',
name='education',
field=models.CharField(blank=True, max_length=128, verbose_name='教师学历'),
),
migrations.AlterField(
model_name='teacher',
name='t_name',
name='name',
field=models.CharField(blank=True, max_length=255, verbose_name='教师名称'),
),
migrations.AlterField(
model_name='teacher',
name='t_sex',
name='sex',
field=models.CharField(blank=True, max_length=128, verbose_name='教师性别'),
),
migrations.AlterField(
model_name='teacher',
name='t_title',
name='title',
field=models.CharField(blank=True, max_length=128, verbose_name='教师职称'),
),
]

Loading…
Cancel
Save