mirror of
https://github.com/gmbrax/Pilgrim.git
synced 2026-11-10 08:20:19 +00:00
- Added `DirectoryManager` utility for consistent directory operations. - Introduced directory name sanitization and uniqueness enforcement for `TravelDiary`. - Updated `TravelDiaryService` with enhanced creation, update, and deletion workflows, including filesystem management. - Improved `PhotoService` to hash files, copy photos to specific diary directories, and manage updates safely. - Refined error handling and cascaded changes across related entities (e.g., `Entry` relationships).
29 lines
937 B
Python
29 lines
937 B
Python
from typing import Any
|
|
|
|
from pilgrim.models.photo_in_entry import photo_entry_association
|
|
from sqlalchemy import Column, Integer, String, ForeignKey, DateTime
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from ..database import Base
|
|
|
|
|
|
class Entry(Base):
|
|
__tablename__ = "entries"
|
|
id = Column(Integer, primary_key=True)
|
|
title = Column(String)
|
|
text = Column(String)
|
|
date = Column(DateTime)
|
|
photos = relationship(
|
|
"Photo",
|
|
secondary=photo_entry_association,
|
|
back_populates="entries")
|
|
fk_travel_diary_id = Column(Integer, ForeignKey("travel_diaries.id"), nullable=False)
|
|
travel_diary = relationship("TravelDiary", back_populates="entries")
|
|
|
|
def __init__(self, title: str, text: str, date: str, travel_diary_id: int, **kw: Any):
|
|
super().__init__(**kw)
|
|
self.title = title
|
|
self.text = text
|
|
self.date = date
|
|
self.fk_travel_diary_id = travel_diary_id
|