Added one more model: Photo.py and edited the Entry.py to add the Many-to-Many relationship to the Photo.py Model

This commit is contained in:
Gustavo Henrique Santos Souza de Miranda 2025-06-03 21:54:13 -03:00
parent 385cdffead
commit 983489d57f
4 changed files with 47 additions and 16 deletions

View File

@ -5,10 +5,9 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="0a7f92e2-b44a-4dfe-8e01-136d1c0c18be" name="Changes" comment=""> <list default="true" id="0a7f92e2-b44a-4dfe-8e01-136d1c0c18be" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/src/Pilgrim/Models/__init__.py" afterDir="false" /> <change afterPath="$PROJECT_DIR$/src/Pilgrim/Models/Photo.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/Pilgrim.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/Pilgrim.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Pilgrim/TravelDiary.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/Pilgrim/Models/TravelDiary.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/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/Pilgrim/__init__.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/Pilgrim/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/Pilgrim/__init__.py" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
@ -24,20 +23,25 @@
</option> </option>
</component> </component>
<component name="Git.Settings"> <component name="Git.Settings">
<option name="RECENT_BRANCH_BY_REPOSITORY">
<map>
<entry key="$PROJECT_DIR$" value="proposed_changes" />
</map>
</option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component> </component>
<component name="GitHubPullRequestSearchHistory"><![CDATA[{ <component name="GitHubPullRequestSearchHistory">{
"lastFilter": { &quot;lastFilter&quot;: {
"state": "OPEN", &quot;state&quot;: &quot;OPEN&quot;,
"assignee": "gmbrax" &quot;assignee&quot;: &quot;gmbrax&quot;
} }
}]]></component> }</component>
<component name="GithubPullRequestsUISettings"><![CDATA[{ <component name="GithubPullRequestsUISettings">{
"selectedUrlAndAccountId": { &quot;selectedUrlAndAccountId&quot;: {
"url": "https://github.com/gmbrax/Pilgrim.git", &quot;url&quot;: &quot;https://github.com/gmbrax/Pilgrim.git&quot;,
"accountId": "213d8456-c67d-4cfd-99a6-337d47c35b4a" &quot;accountId&quot;: &quot;213d8456-c67d-4cfd-99a6-337d47c35b4a&quot;
} }
}]]></component> }</component>
<component name="ProjectColorInfo">{ <component name="ProjectColorInfo">{
&quot;associatedIndex&quot;: 0 &quot;associatedIndex&quot;: 0
}</component> }</component>
@ -54,7 +58,7 @@
"Python.main.executor": "Run", "Python.main.executor": "Run",
"RunOnceActivity.ShowReadmeOnStart": "true", "RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.git.unshallow": "true", "RunOnceActivity.git.unshallow": "true",
"git-widget-placeholder": "proposed__changes", "git-widget-placeholder": "master",
"node.js.detected.package.eslint": "true", "node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true", "node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)", "node.js.selected.package.eslint": "(autodetect)",

View File

@ -1,8 +1,14 @@
from sqlalchemy import Column, Integer, String, ForeignKey from sqlalchemy import Column, Integer, String, ForeignKey, Table
from Pilgrim import Base from Pilgrim import Base
photo_entry_association = Table('photo_entry_association', Base.metadata,
Column('id', Integer, primary_key=True, autoincrement=True),
Column('fk_Photo_id', Integer, ForeignKey('photo.id')),
Column('fk_Entry_id', Integer, ForeignKey('Entry.id')))
class Entry(Base): class Entry(Base):
__tablename__ = "Entry" __tablename__ = "Entry"
id = Column(Integer, primary_key=True) id = Column(Integer, primary_key=True)

View File

@ -0,0 +1,19 @@
from sqlalchemy import Column, Integer, String
from sqlalchemy.orm import relationship
from Pilgrim import Base
from Pilgrim.Models.Entry import photo_entry_association
class Photo(Base):
__tablename__ = "photo"
id = Column(Integer, primary_key=True)
filepath = Column(String)
name = Column(String)
addition_date = Column(String)
caption = Column(String)
entries = relationship(
"Entry",
secondary=photo_entry_association,
back_populates="photos"
)

View File

@ -2,5 +2,7 @@ from Pilgrim.Application import Application
from Pilgrim.command import main from Pilgrim.command import main
from Pilgrim.Database import Database, Base from Pilgrim.Database import Database, Base
from Pilgrim.Models.TravelDiary import TravelDiary from Pilgrim.Models.TravelDiary import TravelDiary
from Pilgrim.Models.Entry import Entry
from Pilgrim.Models.Photo import Photo
__all__ = ["Application", "Database", "TravelDiary", "main", "Base"] __all__ = ["Application", "Database", "TravelDiary", "Entry", "Photo", "main", "Base"]