From 385cdffead29a4de3b5bd0b38b519a5e3861ec8a Mon Sep 17 00:00:00 2001 From: Gustavo Henrique Santos Souza de Miranda Date: Tue, 3 Jun 2025 20:23:44 -0300 Subject: [PATCH 01/27] Added the Entry.py as the Entry model --- .idea/Pilgrim.iml | 1 + .idea/workspace.xml | 71 +++++++++---------------- src/Pilgrim/Models/Entry.py | 12 +++++ src/Pilgrim/{ => Models}/TravelDiary.py | 0 src/Pilgrim/Models/__init__.py | 0 src/Pilgrim/__init__.py | 2 +- 6 files changed, 38 insertions(+), 48 deletions(-) create mode 100644 src/Pilgrim/Models/Entry.py rename src/Pilgrim/{ => Models}/TravelDiary.py (100%) create mode 100644 src/Pilgrim/Models/__init__.py diff --git a/.idea/Pilgrim.iml b/.idea/Pilgrim.iml index 3defecc..3ce9a18 100644 --- a/.idea/Pilgrim.iml +++ b/.idea/Pilgrim.iml @@ -2,6 +2,7 @@ + diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 3586794..1f7c0cb 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,19 +5,11 @@ - - - - - - - - - - - - - + + + + + - - + - + + - { + "lastFilter": { + "state": "OPEN", + "assignee": "gmbrax" } -}]]> - + { + "selectedUrlAndAccountId": { + "url": "https://github.com/gmbrax/Pilgrim.git", + "accountId": "213d8456-c67d-4cfd-99a6-337d47c35b4a" } -}]]> +} { "associatedIndex": 0 } @@ -54,7 +58,7 @@ "Python.main.executor": "Run", "RunOnceActivity.ShowReadmeOnStart": "true", "RunOnceActivity.git.unshallow": "true", - "git-widget-placeholder": "proposed__changes", + "git-widget-placeholder": "master", "node.js.detected.package.eslint": "true", "node.js.detected.package.tslint": "true", "node.js.selected.package.eslint": "(autodetect)", diff --git a/src/Pilgrim/Models/Entry.py b/src/Pilgrim/Models/Entry.py index dfedd58..9f5f860 100644 --- a/src/Pilgrim/Models/Entry.py +++ b/src/Pilgrim/Models/Entry.py @@ -1,8 +1,14 @@ -from sqlalchemy import Column, Integer, String, ForeignKey +from sqlalchemy import Column, Integer, String, ForeignKey, Table 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): __tablename__ = "Entry" id = Column(Integer, primary_key=True) diff --git a/src/Pilgrim/Models/Photo.py b/src/Pilgrim/Models/Photo.py new file mode 100644 index 0000000..69773b9 --- /dev/null +++ b/src/Pilgrim/Models/Photo.py @@ -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" + ) \ No newline at end of file diff --git a/src/Pilgrim/__init__.py b/src/Pilgrim/__init__.py index c1479bf..e5627f1 100644 --- a/src/Pilgrim/__init__.py +++ b/src/Pilgrim/__init__.py @@ -2,5 +2,7 @@ from Pilgrim.Application import Application from Pilgrim.command import main from Pilgrim.Database import Database, Base 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"] From ddb24843a51f34b0ded6916e10a5d24d372d58d8 Mon Sep 17 00:00:00 2001 From: Gustavo Henrique Miranda Date: Tue, 3 Jun 2025 22:01:27 -0300 Subject: [PATCH 03/27] Create pylint.yml --- .github/workflows/pylint.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/pylint.yml diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml new file mode 100644 index 0000000..c73e032 --- /dev/null +++ b/.github/workflows/pylint.yml @@ -0,0 +1,23 @@ +name: Pylint + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10"] + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pylint + - name: Analysing the code with pylint + run: | + pylint $(git ls-files '*.py') From 8d9ac752267a041e6c7436ac290744ad1c1f16e4 Mon Sep 17 00:00:00 2001 From: Gustavo Henrique Miranda Date: Tue, 3 Jun 2025 22:05:16 -0300 Subject: [PATCH 04/27] Update pylint.yml --- .github/workflows/pylint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index c73e032..f07da75 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -20,4 +20,4 @@ jobs: pip install pylint - name: Analysing the code with pylint run: | - pylint $(git ls-files '*.py') + pylint --disable=C0114,C0115,C0116 --exit-zeropylint $(git ls-files '*.py') From c168c693494a9f9b24aaef94447be9cced75ad08 Mon Sep 17 00:00:00 2001 From: Gustavo Henrique Miranda Date: Tue, 3 Jun 2025 22:06:50 -0300 Subject: [PATCH 05/27] Update pylint.yml --- .github/workflows/pylint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index f07da75..b0e73bf 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -20,4 +20,4 @@ jobs: pip install pylint - name: Analysing the code with pylint run: | - pylint --disable=C0114,C0115,C0116 --exit-zeropylint $(git ls-files '*.py') + pylint --disable=C0114,C0115,C0116 --exit-zero $(git ls-files '*.py') From ad95eeab70e703ec693111e3333c88c6e0683842 Mon Sep 17 00:00:00 2001 From: Gustavo Henrique Santos Souza de Miranda Date: Tue, 3 Jun 2025 22:10:16 -0300 Subject: [PATCH 06/27] Added requirements.txt to the project --- requirements.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..4ca3bc7 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +greenlet==3.2.2 +SQLAlchemy==2.0.41 +typing_extensions==4.14.0 From 5e28f63cb8644dcb594bace3f4c348ec60940c81 Mon Sep 17 00:00:00 2001 From: Gustavo Henrique Santos Souza de Miranda Date: Tue, 3 Jun 2025 22:12:38 -0300 Subject: [PATCH 07/27] Added requirements.txt to the project --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 4ca3bc7..f23f26c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ greenlet==3.2.2 SQLAlchemy==2.0.41 typing_extensions==4.14.0 + From 48147120394017702db0a4d69c18966c9e2e5d9f Mon Sep 17 00:00:00 2001 From: Gustavo Henrique Santos Souza de Miranda Date: Tue, 3 Jun 2025 23:28:27 -0300 Subject: [PATCH 08/27] Added a Back Relationship in Entry to list all the photos --- src/Pilgrim/Models/Entry.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Pilgrim/Models/Entry.py b/src/Pilgrim/Models/Entry.py index 9f5f860..6333849 100644 --- a/src/Pilgrim/Models/Entry.py +++ b/src/Pilgrim/Models/Entry.py @@ -1,4 +1,5 @@ from sqlalchemy import Column, Integer, String, ForeignKey, Table +from sqlalchemy.orm import relationship from Pilgrim import Base @@ -15,4 +16,8 @@ class Entry(Base): title = Column(String) text = Column(String) date = Column(String) + photos = relationship( + "Photo", + secondary=photo_entry_association, + back_populates="entries") fk_TravelDiary_id = Column(Integer, ForeignKey("TravelDiary.id")) From 633e200b58c375f7a42ded6400ec4a9c531ecd3f Mon Sep 17 00:00:00 2001 From: Gustavo Henrique Miranda Date: Tue, 3 Jun 2025 23:33:53 -0300 Subject: [PATCH 09/27] Update pylint.yml --- .github/workflows/pylint.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index b0e73bf..9d680dc 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -17,6 +17,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi pip install pylint - name: Analysing the code with pylint run: | From 89e6d0a783f116fb97ff2305342a872c22451759 Mon Sep 17 00:00:00 2001 From: Gustavo Henrique Miranda Date: Tue, 3 Jun 2025 23:35:49 -0300 Subject: [PATCH 10/27] Update pylint.yml --- .github/workflows/pylint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 9d680dc..e1e14af 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10"] + python-version: ["3.10"] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} From ac29e84833282c2006df441e388410e8e94d368a Mon Sep 17 00:00:00 2001 From: Gustavo Henrique Santos Souza de Miranda Date: Wed, 4 Jun 2025 00:13:02 -0300 Subject: [PATCH 11/27] 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 --- .idea/workspace.xml | 59 ++++++++++++------- src/Pilgrim/__init__.py | 8 --- src/pilgrim/__init__.py | 8 +++ .../Application.py => pilgrim/application.py} | 2 +- src/{Pilgrim => pilgrim}/command.py | 2 +- .../Database.py => pilgrim/database.py} | 4 +- .../Models => pilgrim/models}/__init__.py | 0 .../Entry.py => pilgrim/models/entry.py} | 11 +--- .../Photo.py => pilgrim/models/photo.py} | 6 +- src/pilgrim/models/photo_in_entry.py | 8 +++ .../models/travel_diary.py} | 3 +- 11 files changed, 66 insertions(+), 45 deletions(-) delete mode 100644 src/Pilgrim/__init__.py create mode 100644 src/pilgrim/__init__.py rename src/{Pilgrim/Application.py => pilgrim/application.py} (77%) rename src/{Pilgrim => pilgrim}/command.py (54%) rename src/{Pilgrim/Database.py => pilgrim/database.py} (83%) rename src/{Pilgrim/Models => pilgrim/models}/__init__.py (100%) rename src/{Pilgrim/Models/Entry.py => pilgrim/models/entry.py} (53%) rename src/{Pilgrim/Models/Photo.py => pilgrim/models/photo.py} (80%) create mode 100644 src/pilgrim/models/photo_in_entry.py rename src/{Pilgrim/Models/TravelDiary.py => pilgrim/models/travel_diary.py} (81%) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index e459338..70c8282 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -4,11 +4,17 @@