Improved the photo sidebar and add the add_photo_modal.py to add photos and the file_picker_modal.py to select the proper file to be ingested, also changed photo.py and photo_service.py to receive a datatime and not a string representing the addition date

This commit is contained in:
Gustavo Henrique Santos Souza de Miranda
2025-06-29 21:38:33 -03:00
parent 84b0397263
commit f84da2c934
10 changed files with 226 additions and 58 deletions
+14 -6
View File
@@ -1,6 +1,8 @@
from typing import Any
from datetime import datetime
from pathlib import Path
from sqlalchemy import Column, Integer, String, ForeignKey
from sqlalchemy import Column, Integer, String, ForeignKey, DateTime
from sqlalchemy.orm import relationship
from pilgrim.models.photo_in_entry import photo_entry_association
@@ -12,7 +14,7 @@ class Photo(Base):
id = Column(Integer, primary_key=True)
filepath = Column(String)
name = Column(String)
addition_date = Column(String)
addition_date = Column(DateTime, default=datetime.now)
caption = Column(String)
entries = relationship(
"Entry",
@@ -22,10 +24,16 @@ class Photo(Base):
fk_travel_diary_id = Column(Integer, ForeignKey("travel_diaries.id"),nullable=False)
def __init__(self, filepath, name, addition_date=None, caption=None, entries=None, **kw: Any):
def __init__(self, filepath, name, addition_date=None, caption=None, entries=None, fk_travel_diary_id=None, **kw: Any):
super().__init__(**kw)
self.filepath = filepath
# Convert Path to string if needed
if isinstance(filepath, Path):
self.filepath = str(filepath)
else:
self.filepath = filepath
self.name = name
self.addition_date = addition_date
self.addition_date = addition_date if addition_date is not None else datetime.now()
self.caption = caption
self.entries = entries
self.entries = entries if entries is not None else []
if fk_travel_diary_id is not None:
self.fk_travel_diary_id = fk_travel_diary_id