Beispiel #1
0
class Mission(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    created_at = db.Column(db.DateTime, default=datetime.utcnow, index=True)
    name = db.Column(db.String(30))
    unit = db.Column(db.String(10))
    total_missions = db.Column(db.Integer)
    start_at = db.Column(db.DateTime, index=True)
    end_at = db.Column(db.DateTime, index=True)
    total_days = db.Column(db.Integer)
    # daily plan mission
    daily_missions = db.Column(db.Integer)
    # daily plan minutes
    daily_times = db.Column(db.Integer)
    total_times = db.Column(db.Integer)
    total_used_times = db.Column(db.Integer, default=0)
    # current completed mission
    completed_missions = db.Column(db.Integer, default=0)
    # is_completed: 1 yes, 0 no
    is_completed = db.Column(db.Integer, default=0)
    # status = db.Column(db.Integer, default=1)
    # (1 show, 0 hide) in index.html
    is_show = db.Column(db.Integer, default=1)
    summary = db.Column(db.TEXT, default='')

    plan_id = db.Column(db.Integer, db.ForeignKey('plan.id'))
    plan = db.relationship('Plan', back_populates='missions')
    logs = db.relationship('MissionLog', back_populates='mission')
Beispiel #2
0
class Item(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    body = db.Column(db.Text)
    done = db.Column(db.Boolean, default=False)
    author_id = db.Column(db.Integer, db.ForeignKey('user.id'))

    author = db.relationship('User', back_populates='items')
Beispiel #3
0
class Item(db.Model):
    # print('----', '测试断点2')
    id = db.Column(db.Integer, primary_key=True)  # 主键字段
    body = db.Column(db.Text)  # 主体字段
    done = db.Column(db.Boolean, default=False)  # 完成字段
    author_id = db.Column(db.Integer, db.ForeignKey('user.id'))  # author_id字段
    # 通过relationship()函数, 同时通过设置back_populates参数的值为关系另一侧的关系属性名来连接对方。
    author = db.relationship('User', back_populates='items')  # author字段
Beispiel #4
0
class Item(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    author_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    title = db.Column(db.Text)
    sdate = db.Column(db.String())
    stime = db.Column(db.String())
    edate = db.Column(db.String())
    etime = db.Column(db.String())
    author = db.relationship('User', back_populates='items')
Beispiel #5
0
class MissionLog(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    timestamp = db.Column(db.DateTime, default=datetime.utcnow, index=True)
    log_id = db.Column(db.Integer)
    completed_mission = db.Column(db.Integer)
    used_time = db.Column(db.Integer)

    mission_id = db.Column(db.Integer, db.ForeignKey('mission.id'))
    mission = db.relationship('Mission', back_populates='logs')
Beispiel #6
0
class Plan(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    created_at = db.Column(db.DateTime, default=datetime.utcnow, index=True)
    name = db.Column(db.String(30))

    category_id = db.Column(db.Integer, db.ForeignKey('category.id'))
    category = db.relationship('Category', back_populates='plans')

    missions = db.relationship('Mission', back_populates='plan')
Beispiel #7
0
class Item(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    body = db.Column(db.Text)
    done = db.Column(db.Boolean, default=False)
    author_id = db.Column(db.Integer, db.ForeignKey('user.id'))