class CycleScenarios(db.Model): __tablename__ = "cycle_scenarios" __table_args__ = {'extend_existing': True} id = db.Column(db.Integer, primary_key=True) cycle_id = db.Column(db.Integer, db.ForeignKey('cycle.id')) state_code = db.Column(db.Enum(StateType)) scenario_id = db.Column(db.Integer, db.ForeignKey('scenario.id')) last_executed_by = db.Column(db.Integer, db.ForeignKey('user.id')) last_executed_at = db.Column(db.DateTime) def __init__(self, cycle_id, scenario_id): self.cycle_id = cycle_id self.scenario_id = scenario_id self.state_code = StateType.not_executed
class Case(db.Model): __tablename__ = "case" __table_args__ = {'extend_existing': True} id = db.Column(db.Integer, primary_key=True) name = db.Column(db.Text(500), nullable=False) scenario_id = db.Column(db.Integer, db.ForeignKey('scenario.id')) state_code = db.Column(db.Enum(StateType)) def __init__(self, name, scenario_id): self.name = name self.scenario_id = scenario_id self.state_code = StateType.active
class CaseNotes(db.Model): __tablename__ = "notes" __table_args__ = {'extend_existing': True} id = db.Column(db.Integer, primary_key=True) cycle_id = db.Column(db.Integer, db.ForeignKey('cycle.id')) case_id = db.Column(db.Integer) text = db.Column(db.Text) def __init__(self, cycle_id, scenario_id, text): self.cycle_id = cycle_id self.scenario_id = scenario_id self.text = text
class ScenarioNotes(db.Model): __tablename__ = "notes" __table_args__ = {'extend_existing': True} id = db.Column(db.Integer, primary_key=True) cycle_id = db.Column(db.Integer, db.ForeignKey('cycle.id')) scenario_id = db.Column(db.Integer) text = db.Column(db.Text) def __init__(self, cycle_id, scenario_id, text): """Setting params to the object.""" self.cycle_id = cycle_id self.scenario_id = scenario_id self.text = text
class Cycle(db.Model): __tablename__ = "cycle" __table_args__ = {'extend_existing': True} id = db.Column(db.Integer, primary_key=True) cycle = db.Column(db.Integer, nullable=False) name = db.Column(db.Text) project_id = db.Column(db.Integer, db.ForeignKey('project.id')) state_code = db.Column(db.Enum(StateType)) cycle_cases = db.relationship('CycleCases') cycle_scenarios = db.relationship('CycleScenarios') created_at = db.Column(db.DateTime, default=datetime.now) closed_at = db.Column(db.DateTime) closed_by = db.Column(db.Integer, db.ForeignKey('user.id')) closed_reason = db.Column(db.String(250)) last_change = db.Column(db.DateTime, default=datetime.now) def __init__(self, cycle, name, project_id): self.cycle = cycle self.name = name self.project_id = project_id self.state_code = StateType.active
class Scenario(db.Model): __tablename__ = "scenario" __table_args__ = {'extend_existing': True} id = db.Column(db.Integer, primary_key=True) name = db.Column(db.Text, nullable=False) state_code = db.Column(db.Enum(StateType)) project_id = db.Column(db.Integer, db.ForeignKey('project.id')) cycle_scenarios = db.relationship('CycleScenarios') cycle_cases = db.relationship('CycleCases') case = db.relationship('Case') def __init__(self, name, project_id): self.name = name self.project_id = project_id self.state_code = StateType.active
class Project(db.Model): __tablename__ = "project" __table_args__ = {'extend_existing': True} id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(50), nullable=False) owner_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) type_of_project = db.Column(db.String(50), nullable=False) privacy_policy = db.Column(db.String(50), nullable=False) scenario = db.relationship('Scenario') cycle = db.relationship('Cycle') def __init__(self, name, owner_id, type_of_project, privacy_policy): """Setting params to the object.""" self.name = name self.owner_id = owner_id self.type_of_project = type_of_project self.privacy_policy = privacy_policy def __repr__(self): """Representative Object Return.""" return '<Project %r>' % self.name