mirror of https://github.com/gmbrax/Pilgrim.git
Made some changes to naming in both the classes and the tables of the database to conform the correct naming scheme
This commit is contained in:
parent
7e29a590a2
commit
32b8a58c3a
|
|
@ -4,11 +4,17 @@
|
||||||
<option name="autoReloadType" value="SELECTIVE" />
|
<option name="autoReloadType" value="SELECTIVE" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="0a7f92e2-b44a-4dfe-8e01-136d1c0c18be" name="Changes" comment="Added the Services layer to the code to do the database operation">
|
<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 afterPath="$PROJECT_DIR$/src/pilgrim/service/photo_service.py" 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/application.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/pilgrim/application.py" afterDir="false" />
|
||||||
<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/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.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>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
|
|
@ -141,7 +147,15 @@
|
||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1749140898576</updated>
|
<updated>1749140898576</updated>
|
||||||
</task>
|
</task>
|
||||||
<option name="localTasksCounter" value="4" />
|
<task id="LOCAL-00004" summary="Added the photo_service.py and modified photo.py to have all the crud operations">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1749155713848</created>
|
||||||
|
<option name="number" value="00004" />
|
||||||
|
<option name="presentableId" value="LOCAL-00004" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1749155713848</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="5" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="TypeScriptGeneratedFilesManager">
|
<component name="TypeScriptGeneratedFilesManager">
|
||||||
|
|
@ -162,7 +176,8 @@
|
||||||
<MESSAGE value="Added a Back Relationship in Entry to list all the photos" />
|
<MESSAGE value="Added a Back Relationship in Entry to list all the photos" />
|
||||||
<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="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 Services layer to the code to do the database operation" />
|
||||||
<option name="LAST_COMMIT_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" />
|
||||||
</component>
|
</component>
|
||||||
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
<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" />
|
<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" />
|
||||||
|
|
|
||||||
|
|
@ -13,4 +13,4 @@ class Application:
|
||||||
session = self.database.session()
|
session = self.database.session()
|
||||||
session_manager = ServiceManager()
|
session_manager = ServiceManager()
|
||||||
session_manager.set_session(session)
|
session_manager.set_session(session)
|
||||||
return session_manager
|
return session_manager
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ from ..database import Base
|
||||||
|
|
||||||
|
|
||||||
class Entry(Base):
|
class Entry(Base):
|
||||||
__tablename__ = "Entry"
|
__tablename__ = "entries"
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
title = Column(String)
|
title = Column(String)
|
||||||
text = Column(String)
|
text = Column(String)
|
||||||
|
|
@ -17,12 +17,10 @@ class Entry(Base):
|
||||||
"Photo",
|
"Photo",
|
||||||
secondary=photo_entry_association,
|
secondary=photo_entry_association,
|
||||||
back_populates="entries")
|
back_populates="entries")
|
||||||
fk_TravelDiary_id = Column(Integer, ForeignKey("TravelDiary.id"))
|
fk_travel_diary_id = Column(Integer, ForeignKey("travel_diaries.id"))
|
||||||
def __init__(self, title: str, text: str, date: str, travel_diary_id: int, **kw: Any):
|
def __init__(self, title: str, text: str, date: str, travel_diary_id: int, **kw: Any):
|
||||||
super().__init__(**kw)
|
super().__init__(**kw)
|
||||||
self.title = title
|
self.title = title
|
||||||
self.text = text
|
self.text = text
|
||||||
self.date = date
|
self.date = date
|
||||||
self.fk_TravelDiary_id = travel_diary_id
|
self.fk_travel_diary_id = travel_diary_id
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,17 +8,18 @@ from ..database import Base
|
||||||
|
|
||||||
|
|
||||||
class Photo(Base):
|
class Photo(Base):
|
||||||
__tablename__ = "photo"
|
__tablename__ = "photos"
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
filepath = Column(String)
|
filepath = Column(String)
|
||||||
name = Column(String)
|
name = Column(String)
|
||||||
addition_date = Column(String)
|
addition_date = Column(String)
|
||||||
caption = Column(String)
|
caption = Column(String)
|
||||||
entries:relationship = relationship(
|
entries = relationship(
|
||||||
"Entry",
|
"Entry",
|
||||||
secondary=photo_entry_association,
|
secondary=photo_entry_association,
|
||||||
back_populates="photos"
|
back_populates="photos"
|
||||||
)
|
)
|
||||||
|
|
||||||
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, **kw: Any):
|
||||||
super().__init__(**kw)
|
super().__init__(**kw)
|
||||||
self.filepath = filepath
|
self.filepath = filepath
|
||||||
|
|
@ -26,4 +27,3 @@ class Photo(Base):
|
||||||
self.addition_date = addition_date
|
self.addition_date = addition_date
|
||||||
self.caption = caption
|
self.caption = caption
|
||||||
self.entries = entries
|
self.entries = entries
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,5 +4,5 @@ from ..database import Base
|
||||||
|
|
||||||
photo_entry_association = Table('photo_entry_association', Base.metadata,
|
photo_entry_association = Table('photo_entry_association', Base.metadata,
|
||||||
Column('id', Integer, primary_key=True, autoincrement=True),
|
Column('id', Integer, primary_key=True, autoincrement=True),
|
||||||
Column('fk_Photo_id', Integer, ForeignKey('photo.id')),
|
Column('fk_photo_id', Integer, ForeignKey('photos.id')),
|
||||||
Column('fk_Entry_id', Integer, ForeignKey('Entry.id')))
|
Column('fk_entry_id', Integer, ForeignKey('entries.id')))
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ from sqlalchemy import Column, String, Integer
|
||||||
from ..database import Base
|
from ..database import Base
|
||||||
|
|
||||||
class TravelDiary(Base):
|
class TravelDiary(Base):
|
||||||
__tablename__ = "TravelDiary"
|
__tablename__ = "travel_diaries"
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
name = Column(String)
|
name = Column(String)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
|
from typing import List
|
||||||
|
|
||||||
from ..models.entry import Entry
|
from ..models.entry import Entry
|
||||||
from ..models.travel_diary import TravelDiary
|
from ..models.travel_diary import TravelDiary
|
||||||
|
|
@ -20,33 +20,31 @@ class EntryService:
|
||||||
|
|
||||||
return new_entry
|
return new_entry
|
||||||
|
|
||||||
def read_by_id(self,entry_id:int):
|
def read_by_id(self,entry_id:int)->Entry:
|
||||||
entry = self.session.query(Entry).filter(Entry.id == entry_id).first()
|
entry = self.session.query(Entry).filter(Entry.id == entry_id).first()
|
||||||
return entry
|
return entry
|
||||||
|
|
||||||
def read_all(self):
|
def read_all(self)-> List[Entry]:
|
||||||
entries = self.session.query(Entry).all()
|
entries = self.session.query(Entry).all()
|
||||||
return entries
|
return entries
|
||||||
|
|
||||||
def update(self,entry_src:Entry,entry_dst:Entry):
|
def update(self,entry_src:Entry,entry_dst:Entry) -> Entry | None:
|
||||||
original:Entry = self.read_by_id(entry_src.id)
|
original:Entry = self.read_by_id(entry_src.id)
|
||||||
if original:
|
if original:
|
||||||
original.title = entry_dst.title
|
original.title = entry_dst.title
|
||||||
original.text = entry_dst.text
|
original.text = entry_dst.text
|
||||||
original.date = entry_dst.date
|
original.date = entry_dst.date
|
||||||
original.fk_TravelDiary_id = entry_dst.fk_TravelDiary_id
|
original.fk_travel_diary_id = entry_dst.fk_travel_diary_id
|
||||||
original.photos = entry_dst.photos
|
original.photos = entry_dst.photos
|
||||||
self.session.commit()
|
self.session.commit()
|
||||||
self.session.refresh(original)
|
self.session.refresh(original)
|
||||||
return original
|
return original
|
||||||
|
return None
|
||||||
|
|
||||||
def delete(self,entry_src:Entry):
|
def delete(self,entry_src:Entry)-> Entry | None:
|
||||||
excluded = self.read_by_id(entry_src.id)
|
excluded = self.read_by_id(entry_src.id)
|
||||||
if excluded is not None:
|
if excluded is not None:
|
||||||
self.session.delete(excluded)
|
self.session.delete(excluded)
|
||||||
self.session.commit()
|
self.session.commit()
|
||||||
return excluded
|
return excluded
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,4 +43,3 @@ class PhotoService:
|
||||||
self.session.refresh(excluded)
|
self.session.refresh(excluded)
|
||||||
return excluded
|
return excluded
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,4 +16,4 @@ class ServiceManager:
|
||||||
def get_travel_diary_service(self):
|
def get_travel_diary_service(self):
|
||||||
if self.session is not None:
|
if self.session is not None:
|
||||||
return TravelDiaryService(self.session)
|
return TravelDiaryService(self.session)
|
||||||
return None
|
return None
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue