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" />
|
||||
</component>
|
||||
<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">
|
||||
<change afterPath="$PROJECT_DIR$/src/pilgrim/service/photo_service.py" afterDir="false" />
|
||||
<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" />
|
||||
<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" />
|
||||
|
|
@ -141,7 +147,15 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1749140898576</updated>
|
||||
</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 />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
|
|
@ -162,7 +176,8 @@
|
|||
<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="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 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" />
|
||||
|
|
|
|||
|
|
@ -13,4 +13,4 @@ class Application:
|
|||
session = self.database.session()
|
||||
session_manager = ServiceManager()
|
||||
session_manager.set_session(session)
|
||||
return session_manager
|
||||
return session_manager
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ from ..database import Base
|
|||
|
||||
|
||||
class Entry(Base):
|
||||
__tablename__ = "Entry"
|
||||
__tablename__ = "entries"
|
||||
id = Column(Integer, primary_key=True)
|
||||
title = Column(String)
|
||||
text = Column(String)
|
||||
|
|
@ -17,12 +17,10 @@ class Entry(Base):
|
|||
"Photo",
|
||||
secondary=photo_entry_association,
|
||||
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):
|
||||
super().__init__(**kw)
|
||||
self.title = title
|
||||
self.text = text
|
||||
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):
|
||||
__tablename__ = "photo"
|
||||
__tablename__ = "photos"
|
||||
id = Column(Integer, primary_key=True)
|
||||
filepath = Column(String)
|
||||
name = Column(String)
|
||||
addition_date = Column(String)
|
||||
caption = Column(String)
|
||||
entries:relationship = relationship(
|
||||
entries = relationship(
|
||||
"Entry",
|
||||
secondary=photo_entry_association,
|
||||
back_populates="photos"
|
||||
)
|
||||
|
||||
def __init__(self, filepath, name, addition_date=None, caption=None, entries=None, **kw: Any):
|
||||
super().__init__(**kw)
|
||||
self.filepath = filepath
|
||||
|
|
@ -26,4 +27,3 @@ class Photo(Base):
|
|||
self.addition_date = addition_date
|
||||
self.caption = caption
|
||||
self.entries = entries
|
||||
|
||||
|
|
|
|||
|
|
@ -4,5 +4,5 @@ from ..database 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')))
|
||||
Column('fk_photo_id', Integer, ForeignKey('photos.id')),
|
||||
Column('fk_entry_id', Integer, ForeignKey('entries.id')))
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ from sqlalchemy import Column, String, Integer
|
|||
from ..database import Base
|
||||
|
||||
class TravelDiary(Base):
|
||||
__tablename__ = "TravelDiary"
|
||||
__tablename__ = "travel_diaries"
|
||||
id = Column(Integer, primary_key=True)
|
||||
name = Column(String)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
|
||||
from typing import List
|
||||
|
||||
from ..models.entry import Entry
|
||||
from ..models.travel_diary import TravelDiary
|
||||
|
|
@ -20,33 +20,31 @@ class EntryService:
|
|||
|
||||
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()
|
||||
return entry
|
||||
|
||||
def read_all(self):
|
||||
def read_all(self)-> List[Entry]:
|
||||
entries = self.session.query(Entry).all()
|
||||
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)
|
||||
if original:
|
||||
original.title = entry_dst.title
|
||||
original.text = entry_dst.text
|
||||
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
|
||||
self.session.commit()
|
||||
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)
|
||||
if excluded is not None:
|
||||
self.session.delete(excluded)
|
||||
self.session.commit()
|
||||
return excluded
|
||||
return None
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -43,4 +43,3 @@ class PhotoService:
|
|||
self.session.refresh(excluded)
|
||||
return excluded
|
||||
return None
|
||||
|
||||
|
|
|
|||
|
|
@ -16,4 +16,4 @@ class ServiceManager:
|
|||
def get_travel_diary_service(self):
|
||||
if self.session is not None:
|
||||
return TravelDiaryService(self.session)
|
||||
return None
|
||||
return None
|
||||
|
|
|
|||
Loading…
Reference in New Issue