You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.6 KiB

from django.db import models
1 year ago
from teacher.models import Teacher
from Student.models import Student
# Create your models here.
class Course(models.Model):
cid = models.AutoField(primary_key=True, verbose_name="课程编号", name="cid")
name = models.CharField(max_length=255, verbose_name="课程名称", name="name", blank=True)
type = models.CharField(max_length=128, verbose_name="课程类型", name="type", blank=True)
credit = models.IntegerField(verbose_name="课程学分", name="credit")
1 year ago
tid = models.ForeignKey(Teacher, to_field="tid", on_delete=models.CASCADE, name="tid")
def to_dict(self):
1 year ago
return {"cid": self.cid, "c_name": self.name, "type": self.type, "credit": self.credit,
"tid": self.tid}
def tid_dict(self):
return {"cid": self.cid, "c_name": self.name, "type": self.type, "credit": self.credit,
"tid": self.tid.tid}
class Meta:
db_table = "course"
verbose_name = "课程"
verbose_name_plural = verbose_name
class SC(models.Model):
1 year ago
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")
def to_dict(self):
return {"sid": self.sid, "cid": self.cid, "middle_grade": self.middle_grade, "end_grade": self.end_grade}
class Meta:
1 year ago
db_table = "sc"
verbose_name = "管理员"
verbose_name_plural = verbose_name
1 year ago
unique_together = ("sid", "cid")