Пример #1
0
class TaskItem(db.Model):
    """
    任务
    """
    __tablename__ = "task_item"
    TODO = 1
    DONE = 2

    id = db.Column(db.Integer, primary_key=True)
    owner = db.Column(db.Unicode(255))
    name = db.Column(db.Unicode(255))
    status = db.Column(db.Integer, default=TODO)
    desc = db.Column(db.Unicode(255))
    note = db.Column(db.UnicodeText)
    list_id = db.Column(db.Integer)
    due_date = db.Column(db.DateTime, index=True)
    created_at = db.Column(db.DateTime, index=True, default=datetime.now)
    update_at = db.Column(db.DateTime, index=True, default=datetime.now)

    __mapper_args__ = {'order_by': [id]}

    def __repr__(self):
        return '<TaskItem %s>' % self.name

    def __unicode__(self):
        return self.name
Пример #2
0
class Album(db.Model):
    """相册"""

    __tablename__ = "albums"

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.Unicode(64), nullable=False)
    desc = db.Column(db.Unicode(255))
    created_at = db.Column(db.DateTime, index=True, default=datetime.now)
    updated_at = db.Column(db.DateTime, index=True, default=datetime.now)

    __mapper_args__ = {'order_by': [id]}

    def __repr__(self):
        return '<Album %r>' % self.name

    def __unicode__(self):
        return self.name

    @cached_property
    def formated_updated_time(self):
        return self.updated_at.strftime("%Y-%m-%d")

    # 相册相片数
    @cached_property
    def photo_count(self):
        return Photo.query.filter_by(album_id=self.id).count()
Пример #3
0
class TaskList(db.Model):
    __tablename__ = "task_list"

    id = db.Column(db.Integer, primary_key=True)
    owner = db.Column(db.Unicode(255))
    name = db.Column(db.Unicode(255))
    created_at = db.Column(db.DateTime, index=True, default=datetime.now)
    update_at = db.Column(db.DateTime, index=True, default=datetime.now)

    __mapper_args__ = {'order_by': [id]}

    def __repr__(self):
        return '<TaskList %s>' % self.name

    def __unicode__(self):
        return self.name
Пример #4
0
class PhotoGroup(db.Model):
    """
    媒介: 照片或视频
    """
    __tablename__ = "photo_groups"

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.Unicode(255))
    desc = db.Column(db.Unicode(255))
    url = db.Column(db.Unicode(255))
    album_id = db.Column(db.Integer)
    created_at = db.Column(db.DateTime, index=True, default=datetime.now)

    __mapper_args__ = {'order_by': [id]}

    def __repr__(self):
        return '<MediaGroup %s>' % (self.name or self.url)

    def __unicode__(self):
        return self.name