예제 #1
0
파일: Team.py 프로젝트: Puwong/MiMac
class Team(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(64))
    desc = db.Column(db.String(256))
    owner_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    users = db.relationship("TeamUserRelationship",
                            backref="team",
                            lazy='dynamic')
예제 #2
0
파일: Alg.py 프로젝트: Puwong/MiMac
class Alg(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    base = db.Column(db.SmallInteger, default=BaseAlgorithm.Base)  # 基类
    title = db.Column(db.String(128), unique=True)
    config = db.Column(db.String(4096))
    delete = db.Column(db.Boolean, nullable=False, default=False)
    users = db.relationship("AlgUserRelationship",
                            backref="alg",
                            lazy='dynamic')
    images = db.relationship("Image", backref="alg", lazy='dynamic')
예제 #3
0
파일: Image.py 프로젝트: Puwong/MiMac
class Image(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(128))
    uri = db.Column(db.String(128))
    state = db.Column(db.SmallInteger, default=ImageState.WAIT_LABEL)
    freeze = db.Column(db.Boolean, default=False)
    delete = db.Column(db.Boolean, default=False)
    users = db.relationship("ImageUserRelationship",
                            backref="image",
                            lazy='dynamic')
    alg_id = db.Column(db.Integer, db.ForeignKey('alg.id'))

    @property
    def store_uri(self):
        return self.uri + '.raw'
예제 #4
0
class Article(db.Model):
    # 设计成可以分段加载的,一次性把所有的text_node加载进来按时间排序
    # 题目限制 60 个汉字,120 个字符
    # 一段文章的限制为 10000 个汉字
    id = db.Column(db.Integer, primary_key=True)
    owner_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    title = db.Column(db.String(128))
    text_nodes = db.relationship("TextNode", backref="article", lazy='dynamic')
    delete = db.Column(db.Boolean, default=False)
    visitor_count = db.Column(db.Integer, default=0)
    created_at = db.Column(db.Integer, default=time.time)
    modified_at = db.Column(db.Integer, default=time.time, onupdate=time.time)
예제 #5
0
파일: User.py 프로젝트: Puwong/MiMac
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(32), unique=True)
    password = db.Column(db.String(32))
    email = db.Column(db.String(128))
    role = db.Column(db.SmallInteger, default=UserRole.NORMAL)

    delete = db.Column(db.Boolean, nullable=False, default=False)
    pending = db.Column(db.Boolean, nullable=False, default=False)

    articles = db.relationship("Article", backref="owner", lazy='dynamic')
    algs = db.relationship('AlgUserRelationship',
                           backref='user',
                           lazy='dynamic')
    teams = db.relationship("TeamUserRelationship",
                            backref="user",
                            lazy='dynamic')
    my_teams = db.relationship("Team", backref="owner", lazy='dynamic')
    images = db.relationship("ImageUserRelationship",
                             backref="user",
                             lazy='dynamic')
    image_list = association_proxy('images', 'image')
예제 #6
0
class Message(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    type = db.Column(
        db.SmallInteger,
        default=MessageType.NORMAL)  # normal, yes_or_no, must_reply
    reply_message_id = db.Column(db.Integer,
                                 default=0)  # None if no one to reply
    from_user_id = db.Column(db.Integer, nullable=False)
    message_batch_id = db.Column(db.Integer, db.ForeignKey('message_batch.id'))

    context = db.Column(db.String(2048), default='')
    readed = db.Column(db.Boolean, default=False)
    created_at = db.Column(db.Integer, default=time.time)
예제 #7
0
class MessageBatch(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String(128))
    from_user_id = db.Column(db.Integer, index=True)
    to_user_id = db.Column(db.Integer, index=True)
    messages = db.relationship("Message", backref="message_batch", lazy='dynamic')
예제 #8
0
class TextNode(db.Model):
    # 一段文章的限制为 10000 个汉字
    id = db.Column(db.Integer, primary_key=True)
    context = db.Column(db.String(2048))
    created_at = db.Column(db.Integer, default=time.time)
    article_id = db.Column(db.Integer, db.ForeignKey('article.id'))