示例#1
0
class User(db.Document, UserMixin):
    meta = {
        "collection": "user",  # 表名
        "ordering": ["-id"],  # id
        "strict": True  # 自动修改表内容
    }
    username = db.StringField()  # 帐号
    password_hash = db.StringField()  # 密码
    nickname = db.StringField()  # 用户名
    user_course_code = db.SortedListField(
        db.EmbeddedDocumentField(UserCourseCode),
        ordering="course_id",
        reverse=False)
    user_project_code = db.SortedListField(
        db.EmbeddedDocumentField(UserProjectCode),
        ordering="project_id",
        reverse=False)
    superuser = db.BooleanField(default=False)  # 是否为管理员,后续可以用来进入后台(未实现)

    # 密码加密
    def hash_password(self, password):
        self.password_hash = generate_password_hash(password)
        self.save()

    # 密码验证
    def verify_password(self, password):
        return check_password_hash(self.password_hash, password)
示例#2
0
class ProjectModel(db.Document):
    _id = db.ObjectIdField()
    project_id = db.IntField()
    title = db.StringField()
    text = db.StringField()
    test = db.StringField()
    meta = {"collection": "project", "strict": "False"}
示例#3
0
class EmbeddedModuleModal(db.EmbeddedDocument):
    _id = db.ObjectIdField()
    module_name = db.StringField()
    order = db.IntField(unique_with='module_name')
    sub_modules = db.SortedListField(db.EmbeddedDocumentField(SubModule),
                                     ordering="sub_order",
                                     reverse=False)
示例#4
0
class ModuleModel(db.Document):
    _id = db.ObjectIdField()
    module_name = db.StringField()
    order = db.IntField(unique_with='module_name')
    sub_modules = db.SortedListField(db.EmbeddedDocumentField(SubModule),
                                     ordering="sub_order",
                                     reverse=False)
    meta = {"collection": "module", "strict": "False", 'ordering': ['-order']}
示例#5
0
class CourseModel(db.Document):
    _id = db.ObjectIdField()
    course_id = db.IntField()
    title = db.StringField()
    text = db.StringField()
    goal = db.StringField()
    frame_head = db.StringField()
    frame_foot = db.StringField()
    code = db.StringField()
    concept = db.SortedListField(
        db.ReferenceField(Concept, reverse_delete_rule=PULL))
    meta = {"collection": "course", "strict": "False"}
示例#6
0
class UserProjectCode(db.EmbeddedDocument):
    project_id = db.StringField()
    html_code = db.StringField()
    css_code = db.StringField()
    js_code = db.StringField()
    add_js = db.SortedListField(db.StringField())
示例#7
0
class UserCourseCode(db.EmbeddedDocument):
    course_id = db.StringField()
    code = db.StringField()
示例#8
0
class Concept(db.Document):
    _id = db.ObjectIdField()
    name = db.StringField(unique=True)
示例#9
0
class Unit(db.EmbeddedDocument):
    unit_id = db.ObjectIdField()
    unit_title = db.StringField()
    unit_order = db.IntField()
    unit_type = db.StringField()
示例#10
0
class SubModule(db.EmbeddedDocument):
    sub_id = db.ObjectIdField()
    sub_order = db.IntField()
    type = db.StringField()