Exemplo n.º 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)
Exemplo n.º 2
0
class CategoryModel(db.Document):
    modules = db.SortedListField(db.EmbeddedDocumentField(EmbeddedModuleModal),
                                 ordering='order',
                                 reverse=False)
    units = db.SortedListField(db.EmbeddedDocumentField(Unit),
                               ordering='unit_order',
                               reverse=False)
    meta = {
        "collection": "category",
        "strict": "False",
    }
Exemplo n.º 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)
Exemplo n.º 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']}
Exemplo n.º 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"}
Exemplo n.º 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())