Added the foreign key in photo.py to the travel_diary table so a photo is contained in a diary

This commit is contained in:
Gustavo Henrique Santos Souza de Miranda 2025-06-05 20:02:41 -03:00
parent 32b8a58c3a
commit f556d6906a
2 changed files with 15 additions and 13 deletions

View File

@ -4,17 +4,8 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="0a7f92e2-b44a-4dfe-8e01-136d1c0c18be" name="Changes" comment="Added the photo_service.py and modified photo.py to have all the crud operations">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pilgrim/application.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/pilgrim/application.py" afterDir="false" />
<list default="true" id="0a7f92e2-b44a-4dfe-8e01-136d1c0c18be" name="Changes" comment="Made some changes to naming in both the classes and the tables of the database to conform the correct naming scheme">
<change beforePath="$PROJECT_DIR$/src/pilgrim/command.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/pilgrim/command.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pilgrim/models/entry.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/pilgrim/models/entry.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pilgrim/models/photo.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/pilgrim/models/photo.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pilgrim/models/photo_in_entry.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/pilgrim/models/photo_in_entry.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pilgrim/models/travel_diary.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/pilgrim/models/travel_diary.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pilgrim/service/entry_service.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/pilgrim/service/entry_service.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pilgrim/service/photo_service.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/pilgrim/service/photo_service.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pilgrim/service/servicemanager.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/pilgrim/service/servicemanager.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -155,7 +146,15 @@
<option name="project" value="LOCAL" />
<updated>1749155713848</updated>
</task>
<option name="localTasksCounter" value="5" />
<task id="LOCAL-00005" summary="Made some changes to naming in both the classes and the tables of the database to conform the correct naming scheme">
<option name="closed" value="true" />
<created>1749164385581</created>
<option name="number" value="00005" />
<option name="presentableId" value="LOCAL-00005" />
<option name="project" value="LOCAL" />
<updated>1749164385581</updated>
</task>
<option name="localTasksCounter" value="6" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@ -177,7 +176,8 @@
<MESSAGE value="Changed the names of the files to conform the python convection and also added photo_in_entry.py to diminish the cyclic import error in pylint" />
<MESSAGE value="Added the Services layer to the code to do the database operation" />
<MESSAGE value="Added the photo_service.py and modified photo.py to have all the crud operations" />
<option name="LAST_COMMIT_MESSAGE" value="Added the photo_service.py and modified photo.py to have all the crud operations" />
<MESSAGE value="Made some changes to naming in both the classes and the tables of the database to conform the correct naming scheme" />
<option name="LAST_COMMIT_MESSAGE" value="Made some changes to naming in both the classes and the tables of the database to conform the correct naming scheme" />
</component>
<component name="com.intellij.coverage.CoverageDataManagerImpl">
<SUITE FILE_PATH="coverage/Pilgrim$Database.coverage" NAME="Database Coverage Results" MODIFIED="1748987101492" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/src/Database" />

View File

@ -1,6 +1,6 @@
from typing import Any
from sqlalchemy import Column, Integer, String
from sqlalchemy import Column, Integer, String, ForeignKey
from sqlalchemy.orm import relationship
from pilgrim.models.photo_in_entry import photo_entry_association
@ -20,6 +20,8 @@ class Photo(Base):
back_populates="photos"
)
fk_travel_diary_id = Column(Integer, ForeignKey("travel_diaries.id"))
def __init__(self, filepath, name, addition_date=None, caption=None, entries=None, **kw: Any):
super().__init__(**kw)
self.filepath = filepath