From 7274c3dc41c83ee07239fc54e2af2356176489c2 Mon Sep 17 00:00:00 2001 From: Wudext Date: Thu, 2 Feb 2023 19:10:43 +0300 Subject: [PATCH 01/35] Adding #10 --- .idea/inspectionProfiles/Project_Default.xml | 28 ++++++++ .../inspectionProfiles/profiles_settings.xml | 6 ++ .idea/misc.xml | 4 ++ .idea/modules.xml | 8 +++ .idea/services-api.iml | 14 ++++ .idea/vcs.xml | 6 ++ .idea/workspace.xml | 69 +++++++++++++++++++ migrations/versions/670f4caac7dd_init.py | 29 -------- services_backend/models/database.py | 16 +++++ services_backend/routes/button.py | 7 ++ services_backend/routes/models/button.py | 8 ++- 11 files changed, 165 insertions(+), 30 deletions(-) create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/services-api.iml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml delete mode 100644 migrations/versions/670f4caac7dd_init.py diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..fd95cf1 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,28 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..dc9ea49 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..46ca921 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/services-api.iml b/.idea/services-api.iml new file mode 100644 index 0000000..09bfacf --- /dev/null +++ b/.idea/services-api.iml @@ -0,0 +1,14 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..fc27f64 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1668873105756 + + + + + + + \ No newline at end of file diff --git a/migrations/versions/670f4caac7dd_init.py b/migrations/versions/670f4caac7dd_init.py deleted file mode 100644 index 3f30c54..0000000 --- a/migrations/versions/670f4caac7dd_init.py +++ /dev/null @@ -1,29 +0,0 @@ -from alembic import op -import sqlalchemy as sa - -revision = '670f4caac7dd' -down_revision = None -branch_labels = None -depends_on = None - - -def upgrade(): - op.create_table('category', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('name', sa.String(), nullable=True), - sa.Column('type', sa.String(), nullable=True), - sa.PrimaryKeyConstraint('id') - ) - op.create_table('button', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('name', sa.String(), nullable=True), - sa.Column('category_id', sa.Integer(), nullable=True), - sa.Column('icon', sa.String(), nullable=True), - sa.ForeignKeyConstraint(['category_id'], ['category.id'], ), - sa.PrimaryKeyConstraint('id') - ) - - -def downgrade(): - op.drop_table('button') - op.drop_table('category') diff --git a/services_backend/models/database.py b/services_backend/models/database.py index 31c0685..dd0f111 100644 --- a/services_backend/models/database.py +++ b/services_backend/models/database.py @@ -1,5 +1,11 @@ +<<<<<<< Updated upstream from sqlalchemy import Column, Integer, String, ForeignKey from sqlalchemy.orm import relationship +======= +from __future__ import annotations +from sqlalchemy import Integer, String, ForeignKey, PickleType +from sqlalchemy.orm import relationship, Mapped, mapped_column +>>>>>>> Stashed changes from .base import Base @@ -11,8 +17,18 @@ class Category(Base): class Button(Base): +<<<<<<< Updated upstream id = Column(Integer, primary_key=True) name = Column(String) category_id = Column(Integer, ForeignKey(Category.id)) category = relationship("Category", back_populates="buttons", foreign_keys=[category_id]) icon = Column(String) +======= + id: Mapped[int] = mapped_column(Integer, primary_key=True) + name: Mapped[str] = mapped_column(String) + order: Mapped[int] = mapped_column(Integer) + category_id: Mapped[int] = mapped_column(Integer, ForeignKey(Category.id)) + category: Mapped[Category] = relationship("Category", back_populates="buttons", foreign_keys=[category_id]) + icon: Mapped[str] = mapped_column(String) + link: Mapped[dict] = mapped_column(PickleType) +>>>>>>> Stashed changes diff --git a/services_backend/routes/button.py b/services_backend/routes/button.py index e4955e1..cfcd073 100644 --- a/services_backend/routes/button.py +++ b/services_backend/routes/button.py @@ -13,6 +13,13 @@ def create_button(button_inp: ButtonCreate): if not category: raise HTTPException(status_code=404, detail="Category does not exist") button = Button(**button_inp.dict()) +<<<<<<< Updated upstream +======= + + db.session.query(Button) \ + .filter(Button.order < button_inp.order) \ + .update({"order": Button.order + 1}) +>>>>>>> Stashed changes db.session.add(button) db.session.flush() return button diff --git a/services_backend/routes/models/button.py b/services_backend/routes/models/button.py index d608542..e2c31e0 100644 --- a/services_backend/routes/models/button.py +++ b/services_backend/routes/models/button.py @@ -5,12 +5,17 @@ class ButtonCreate(Base): category_id: int icon: str | None name: str | None - + link: dict | None class ButtonUpdate(Base): category_id: int | None icon: str | None name: str | None +<<<<<<< Updated upstream +======= + order: int | None + link: dict | None +>>>>>>> Stashed changes class ButtonGet(Base): @@ -18,3 +23,4 @@ class ButtonGet(Base): category_id: int icon: str | None name: str | None + link: dict | None From f2fbb3bc4b44a105ec605fb5a2625996e52df45e Mon Sep 17 00:00:00 2001 From: Wudext Date: Thu, 2 Feb 2023 19:11:18 +0300 Subject: [PATCH 02/35] Adding #10 --- .idea/workspace.xml | 9 +-------- services_backend/models/database.py | 8 -------- services_backend/routes/button.py | 4 ---- 3 files changed, 1 insertion(+), 20 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index fc27f64..079d60d 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,14 +1,7 @@ - - - - - - - - +