示例#1
0
文件: models.py 项目: sujieyang/West2
class Class(db.Model):
    __table_args__ = {"useexisting": True}
    # 班级id
    id = db.Column(db.Integer, primary_key=True)
    # 班级名
    class_name = db.Column(db.String(100), nullable=False)
    # 班级描述
    info = db.Column(db.String(255), default="该班级暂无描述")
    # 班级作业,与作业表关联
    assignments = db.relationship("Assignment",
                                  back_populates="belong_class",
                                  cascade="all")
    # 班级学生,与用户表关联
    stds = db.relationship("User",
                           back_populates="user_classes",
                           secondary=association_table)
    # 班级的讨论
    talkings = db.relationship("Talkings",
                               back_populates="belong_class",
                               cascade="all")
    # 班级视频目录
    categories = db.relationship("FirstCategory",
                                 back_populates="belong_class",
                                 cascade="all")
    # 班级公告
    notices = db.relationship("Notices",
                              back_populates="belong_class",
                              cascade="all")
示例#2
0
文件: models.py 项目: sujieyang/West2
class BaseModel:
    # id
    id = db.Column(db.Integer, primary_key=True)
    # 账号
    account = db.Column(db.String(120), nullable=False, unique=True)
    # 姓名
    username = db.Column(db.String(60), nullable=False)
    # 密码
    password = db.Column(db.String(100), nullable=False)
    # 手机
    mobile = db.Column(db.String(100), default="未填写", unique=True)
    # 邮箱
    email = db.Column(db.String(100), default="未填写", unique=True)
    # 学校
    college = db.Column(db.String(100), nullable=False, default="未填写")
    # 简介
    info = db.Column(db.String(255), default="该用户未填写简介~")
    # 性别,True为男
    gender = db.Column(db.Boolean, nullable=False, default=True)
    # 创建时间
    create_time = db.Column(db.DateTime, default=datetime.utcnow)
    # 用户头像
    avatar = db.Column(db.String(255), default="default")
    # 总学习时长
    total_study = db.Column(db.Integer, default=0)
示例#3
0
文件: models.py 项目: sujieyang/West2
class Notices(db.Model):
    __table_args__ = {"useexisting": True}
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(255), nullable=False)
    content = db.Column(db.Text, nullable=False)
    belong_class = db.relationship("Class", back_populates="notices")
    belong_class_id = db.Column(db.Integer, db.ForeignKey("class.id"))
    create_time = db.Column(db.DateTime, default=datetime.utcnow)
示例#4
0
文件: models.py 项目: sujieyang/West2
class SecondCategory(db.Model):
    __table_args__ = {"useexisting": True}

    __tablename__ = "second_category"
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(255))
    # 属于的父级目录
    parent_category = db.relationship("FirstCategory",
                                      back_populates="sub_categories")
    parent_category_id = db.Column(db.Integer,
                                   db.ForeignKey("first_category.id"))
    # 该目录对应的视频地址
    movie = db.Column(db.String(255))
    # 该二级目录对应的作业
    assignment = db.relationship("Assignment",
                                 back_populates="belong_category",
                                 cascade="all")
    # 该二级目录添加的时间
    add_time = db.Column(db.DateTime, default=datetime.utcnow)
示例#5
0
文件: models.py 项目: sujieyang/West2
class Assignment(db.Model):
    __table_args__ = {"useexisting": True}
    # 作业id
    id = db.Column(db.Integer, primary_key=True)
    # 作业标题
    title = db.Column(db.String(255), nullable=False)
    # 作业内容 -->
    content = db.Column(db.Text, nullable=False)
    # 作业发布日期
    publish_date = db.Column(db.DateTime, default=datetime.utcnow)
    # 作业所属目录,与SecondCategory表关联
    belong_category = db.relationship("SecondCategory",
                                      back_populates="assignment")
    belong_category_id = db.Column(db.Integer,
                                   db.ForeignKey("second_category.id"))
    # 作业所属的班级
    belong_class = db.relationship("Class", back_populates="assignments")
    belong_class_id = db.Column(db.Integer, db.ForeignKey("class.id"))
    # 作业选择题对应的答案-->"A,B,C"
    answer = db.Column(db.String(255))
    # 该作业的完成情况
    finish_status = db.relationship("FinishStatus",
                                    back_populates="assignment",
                                    cascade="all")
示例#6
0
文件: models.py 项目: sujieyang/West2
class FirstCategory(db.Model):
    __table_args__ = {"useexisting": True}
    __tablename__ = "first_category"
    id = db.Column(db.Integer, primary_key=True)
    # 目录名
    name = db.Column(db.String(255))
    # 该目录属于的班级
    belong_class = db.relationship("Class", back_populates="categories")
    belong_class_id = db.Column(db.Integer, db.ForeignKey("class.id"))
    # 该目录下的二级目录
    sub_categories = db.relationship("SecondCategory",
                                     back_populates="parent_category",
                                     cascade="all")
    # 下一个一级目录的id,若下一个没有了则为0
    next_category_id = db.Column(db.Integer, default=0)
    # 该目录是否是第一个目录
    is_first_category = db.Column(db.Boolean, default=False)
示例#7
0
文件: models.py 项目: sujieyang/West2
class Talkings(db.Model):
    __table_args__ = {"useexisting": True}

    # id
    id = db.Column(db.Integer, primary_key=True)
    # 讨论题目
    title = db.Column(db.String(255), nullable=False)
    # 讨论内容
    content = db.Column(db.Text, nullable=False)
    # 讨论回复,与评论类关联
    comments = db.relationship("Comments",
                               back_populates="belong_talking",
                               cascade="all")
    # 讨论所属班级
    belong_class = db.relationship("Class", back_populates="talkings")
    belong_class_id = db.Column(db.Integer, db.ForeignKey("class.id"))
    # 公开时间
    publish_time = db.Column(db.DateTime, default=datetime.utcnow)
    # 发起用户
    publish_user = db.relationship("User", back_populates="talkings")
    publish_user_id = db.Column(db.Integer, db.ForeignKey("user.id"))