mirror of
https://github.com/DRYTRIX/TimeTracker.git
synced 2026-05-23 06:40:53 -05:00
90dde470da
- Normalize line endings from CRLF to LF across all files to match .editorconfig - Standardize quote style from single quotes to double quotes - Normalize whitespace and formatting throughout codebase - Apply consistent code style across 372 files including: * Application code (models, routes, services, utils) * Test files * Configuration files * CI/CD workflows This ensures consistency with the project's .editorconfig settings and improves code maintainability.
29 lines
1.1 KiB
Python
29 lines
1.1 KiB
Python
from datetime import datetime
|
|
from app import db
|
|
|
|
|
|
class UserFavoriteProject(db.Model):
|
|
"""Association table for user favorite projects"""
|
|
|
|
__tablename__ = "user_favorite_projects"
|
|
|
|
id = db.Column(db.Integer, primary_key=True)
|
|
user_id = db.Column(db.Integer, db.ForeignKey("users.id", ondelete="CASCADE"), nullable=False, index=True)
|
|
project_id = db.Column(db.Integer, db.ForeignKey("projects.id", ondelete="CASCADE"), nullable=False, index=True)
|
|
created_at = db.Column(db.DateTime, default=datetime.utcnow, nullable=False)
|
|
|
|
# Unique constraint to prevent duplicate favorites
|
|
__table_args__ = (db.UniqueConstraint("user_id", "project_id", name="uq_user_project_favorite"),)
|
|
|
|
def __repr__(self):
|
|
return f"<UserFavoriteProject user_id={self.user_id} project_id={self.project_id}>"
|
|
|
|
def to_dict(self):
|
|
"""Convert to dictionary for API responses"""
|
|
return {
|
|
"id": self.id,
|
|
"user_id": self.user_id,
|
|
"project_id": self.project_id,
|
|
"created_at": self.created_at.isoformat() if self.created_at else None,
|
|
}
|