feat: add photos to daily reports

This commit is contained in:
Арсентьев Александр
2026-10-15 14:42:04 +03:00
parent 1af2a70406
commit 3a3e481750
14 changed files with 1765 additions and 20 deletions
+47
View File
@@ -0,0 +1,47 @@
"""Daily Report photo metadata.
Photo files live in the managed application storage, never in SQLite. This
table keeps metadata and the link to the owning Daily Report. Binary content
is not stored here.
Photos are attached to the Daily Report as a whole (REQ), not to individual
work positions.
"""
from sqlalchemy import (
Column,
DateTime,
ForeignKey,
Integer,
String,
)
from sqlalchemy.orm import relationship
from sqlalchemy.sql import func
from app.database.database import Base
class DailyReportPhoto(Base):
__tablename__ = "daily_report_photos"
id = Column(Integer, primary_key=True, index=True)
project_id = Column(Integer, ForeignKey("projects.id"), nullable=False, index=True)
daily_report_id = Column(
Integer, ForeignKey("daily_reports.id"), nullable=False, index=True
)
# Relative path under DOCUMENT_STORAGE_ROOT. Never an absolute path or URL.
storage_key = Column(String, nullable=False)
# Display-only label from the uploader. Never used to build a path.
original_name = Column(String, nullable=True)
content_type = Column(String(100), nullable=False)
file_size = Column(Integer, nullable=False)
content_hash = Column(String(64), nullable=False)
sort_order = Column(Integer, nullable=False, default=0, server_default="0")
created_at = Column(DateTime, nullable=False, server_default=func.now())
report = relationship("DailyReport", back_populates="photos")
def __repr__(self):
return (
f"<DailyReportPhoto(id={self.id}, report={self.daily_report_id}, "
f"size={self.file_size}, type={self.content_type!r})>"
)