Files
TimeTracker/app/models/task_activity.py
Dries Peeters 90dde470da style: standardize code formatting and normalize line endings
- 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.
2025-11-28 20:05:37 +01:00

28 lines
1.1 KiB
Python

from app import db
from app.utils.timezone import now_in_app_timezone
class TaskActivity(db.Model):
"""Lightweight audit log for significant task events."""
__tablename__ = "task_activities"
id = db.Column(db.Integer, primary_key=True)
task_id = db.Column(db.Integer, db.ForeignKey("tasks.id"), nullable=False, index=True)
user_id = db.Column(db.Integer, db.ForeignKey("users.id"), nullable=True, index=True)
event = db.Column(db.String(50), nullable=False, index=True)
details = db.Column(db.Text, nullable=True)
created_at = db.Column(db.DateTime, default=now_in_app_timezone, nullable=False, index=True)
task = db.relationship("Task", backref=db.backref("activities", lazy="dynamic", cascade="all, delete-orphan"))
user = db.relationship("User")
def __init__(self, task_id, event, user_id=None, details=None):
self.task_id = task_id
self.user_id = user_id
self.event = event
self.details = details
def __repr__(self):
return f"<TaskActivity task={self.task_id} event={self.event}>"