Add files via upload

This commit is contained in:
jasonMPM
2026-03-05 12:13:22 -06:00
committed by GitHub
parent bfa3887e61
commit 20e71ee7f9
40 changed files with 1352 additions and 368 deletions

51
backend/app/models.py Normal file
View File

@@ -0,0 +1,51 @@
from .extensions import db
from datetime import datetime
class Project(db.Model):
__tablename__ = 'projects'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(200), nullable=False)
color = db.Column(db.String(7), nullable=False, default='#C9A84C')
description = db.Column(db.Text)
created_at = db.Column(db.DateTime, default=datetime.utcnow)
deliverables = db.relationship(
'Deliverable', backref='project',
cascade='all, delete-orphan', lazy=True
)
def to_dict(self, include_deliverables=True):
data = {
'id': self.id,
'name': self.name,
'color': self.color,
'description': self.description,
'created_at': self.created_at.isoformat() if self.created_at else None,
}
if include_deliverables:
data['deliverables'] = [
d.to_dict() for d in sorted(self.deliverables, key=lambda x: x.due_date)
]
return data
class Deliverable(db.Model):
__tablename__ = 'deliverables'
id = db.Column(db.Integer, primary_key=True)
project_id = db.Column(db.Integer, db.ForeignKey('projects.id', ondelete='CASCADE'), nullable=False)
title = db.Column(db.String(300), nullable=False)
due_date = db.Column(db.Date, nullable=False)
status = db.Column(db.String(20), nullable=False, default='upcoming')
created_at = db.Column(db.DateTime, default=datetime.utcnow)
def to_dict(self):
return {
'id': self.id,
'project_id': self.project_id,
'title': self.title,
'due_date': self.due_date.isoformat() if self.due_date else None,
'status': self.status,
'created_at': self.created_at.isoformat() if self.created_at else None,
}