class WorkLog(db.Model): id = db.Column(db.Integer, primary_key=True) content = db.Column(db.Text, nullable=False) date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) task_id = db.Column(db.Integer, db.ForeignKey('task.id'), nullable=False) def __repr__(self): return f'Comment({self.id} {self.date} {self.user_id})'
class Collaborator(db.Model): id = db.Column(db.Integer, primary_key=True) prid = db.Column(db.String(120), db.ForeignKey('project.id'), nullable=False) userid = db.Column(db.String(120), db.ForeignKey('user.id'), nullable=False) def __repr__(self): return f"User('{self.id}', '{self.prid}', '{self.userid}')"
class Task(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(100), nullable=False) content = db.Column(db.Text, nullable=False) comments = db.relationship('Comment', backref='task', lazy=True) worklogs = db.relationship('WorkLog', backref='task', lazy=True) user_id = db.Column(db.Integer, db.ForeignKey('user.id')) project_id = db.Column(db.Integer, db.ForeignKey('project.id')) type_id = db.Column(db.Integer, db.ForeignKey('task_type.id'), nullable=False) def __repr__(self): return f'{self.id} {self.title} {self.iser_id} {self.type_id}'
class Bug(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(120), unique=True, nullable=False) prid = db.Column(db.String(120), db.ForeignKey('project.id'), nullable=False) date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) prio = db.Column(db.String(60), nullable=False) status = db.Column(db.String(60), nullable=False) desc = db.Column(db.String(500), nullable=False) comments = db.relationship('Bugcomment', backref='bug', lazy=True) userid = db.Column(db.String(120), db.ForeignKey('user.id'), nullable=False) def __repr__(self): return f"User('{self.id}', '{self.prid}', '{self.name}', '{self.date}', '{self.prio}', '{self.status}', '{self.userid}')"
class Bugcomment(db.Model): id = db.Column(db.Integer, primary_key=True) bugid = db.Column(db.String(120), db.ForeignKey('project.id'), nullable=False) comment = db.Column(db.String(500), nullable=False) date = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) def __repr__(self): return f"User('{self.id}', '{self.bugid}', '{self.comment}', '{self.date}')"
class Ticket(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(100), nullable=False) date_posted = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) date_finished = db.Column(db.DateTime) content = db.Column(db.Text, nullable=False) state = db.Column( db.Text, nullable=False, default="pending") #pending, working on it, fixed, rejected severity = db.Column(db.Text, nullable=False) #minor, functional, critical user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) def __repr__(self): return f"Ticket('{self.title}', '{self.date_posted}')"
class Post(db.Model): id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(100), nullable=False) date_posted = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) Description = db.Column(db.String(100), nullable=False) AssignedTo = db.Column(db.String(20), nullable=False) Createdby = db.Column(db.Integer, db.ForeignKey('user.AccessToken'), nullable=False) Status = db.Column(db.Boolean, default=True) def __repr__(self): return "Post('{}','{}', '{}','{}','{}','{}')".format( self.id, self.title, self.date_posted, self.Createdby, self.AssignedTo, self.date_posted)