Add files via upload

This commit is contained in:
jasonMPM
2026-03-06 00:03:06 -06:00
committed by GitHub
parent 118c186881
commit 59619c4ed1
6 changed files with 211 additions and 83 deletions

View File

@@ -1,6 +1,7 @@
from .extensions import db
from datetime import datetime, date
class Project(db.Model):
__tablename__ = 'projects'
@@ -9,11 +10,14 @@ class Project(db.Model):
color = db.Column(db.String(7), nullable=False, default='#C9A84C')
description = db.Column(db.Text)
drive_url = db.Column(db.String(500))
archived_at = db.Column(db.DateTime, nullable=True)
created_at = db.Column(db.DateTime, default=datetime.utcnow)
deliverables = db.relationship(
'Deliverable', backref='project',
cascade='all, delete-orphan', lazy=True
'Deliverable',
backref='project',
cascade='all, delete-orphan',
lazy=True,
)
def to_dict(self, include_deliverables=True):
@@ -23,6 +27,7 @@ class Project(db.Model):
'color': self.color,
'description': self.description,
'drive_url': self.drive_url,
'archived_at': self.archived_at.isoformat() if self.archived_at else None,
'created_at': self.created_at.isoformat() if self.created_at else None,
}
if include_deliverables:
@@ -36,7 +41,11 @@ 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)
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')
@@ -44,9 +53,8 @@ class Deliverable(db.Model):
def effective_status(self):
"""
Returns 'overdue' if the due date has passed and the deliverable
has not been marked completed. Completed deliverables are never
auto-downgraded regardless of date.
Returns 'overdue' if the due date has passed and the deliverable has not been
marked completed. Completed deliverables are never auto-downgraded.
"""
if self.status != 'completed' and self.due_date < date.today():
return 'overdue'