Skip to content

Commit 9c53aa8

Browse files
committed
Refactor in progress code
1. ruff format and fix 2. regenerate alembic revision 3. use sqlalchemy 2 syntax
1 parent a4b1189 commit 9c53aa8

File tree

9 files changed

+110
-173
lines changed

9 files changed

+110
-173
lines changed

server/alembic_config/versions/18660a2d5398_add_crew_table.py

Lines changed: 0 additions & 40 deletions
This file was deleted.

server/alembic_config/versions/5055c78fdf46_add_scenery_and_prop_allocations.py

Lines changed: 0 additions & 68 deletions
This file was deleted.

server/alembic_config/versions/9161f286a179_add_scenery_and_props.py

Lines changed: 0 additions & 52 deletions
This file was deleted.
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
"""Add crew, props and scenery tables and allocations
2+
3+
Revision ID: fa27b233d26c
4+
Revises: 01fb1d6c6b08
5+
Create Date: 2026-01-14 00:38:40.210710
6+
7+
"""
8+
9+
from typing import Sequence, Union
10+
11+
import sqlalchemy as sa
12+
from alembic import op
13+
14+
15+
# revision identifiers, used by Alembic.
16+
revision: str = "fa27b233d26c"
17+
down_revision: Union[str, None] = "01fb1d6c6b08"
18+
branch_labels: Union[str, Sequence[str], None] = None
19+
depends_on: Union[str, Sequence[str], None] = None
20+
21+
22+
def upgrade() -> None:
23+
# ### commands auto generated by Alembic - please adjust! ###
24+
op.create_table(
25+
"crew",
26+
sa.Column("id", sa.Integer(), nullable=False),
27+
sa.Column("show_id", sa.Integer(), nullable=False),
28+
sa.Column("first_name", sa.String(), nullable=True),
29+
sa.Column("last_name", sa.String(), nullable=True),
30+
sa.ForeignKeyConstraint(
31+
["show_id"], ["shows.id"], name=op.f("fk_crew_show_id_shows")
32+
),
33+
sa.PrimaryKeyConstraint("id", name=op.f("pk_crew")),
34+
)
35+
op.create_table(
36+
"props",
37+
sa.Column("id", sa.Integer(), nullable=False),
38+
sa.Column("show_id", sa.Integer(), nullable=False),
39+
sa.Column("name", sa.String(), nullable=True),
40+
sa.Column("description", sa.String(), nullable=True),
41+
sa.ForeignKeyConstraint(
42+
["show_id"], ["shows.id"], name=op.f("fk_props_show_id_shows")
43+
),
44+
sa.PrimaryKeyConstraint("id", name=op.f("pk_props")),
45+
)
46+
op.create_table(
47+
"scenery",
48+
sa.Column("id", sa.Integer(), nullable=False),
49+
sa.Column("show_id", sa.Integer(), nullable=False),
50+
sa.Column("name", sa.String(), nullable=True),
51+
sa.Column("description", sa.String(), nullable=True),
52+
sa.ForeignKeyConstraint(
53+
["show_id"], ["shows.id"], name=op.f("fk_scenery_show_id_shows")
54+
),
55+
sa.PrimaryKeyConstraint("id", name=op.f("pk_scenery")),
56+
)
57+
op.create_table(
58+
"props_allocation",
59+
sa.Column("id", sa.Integer(), nullable=False),
60+
sa.Column("props_id", sa.Integer(), nullable=False),
61+
sa.Column("scene_id", sa.Integer(), nullable=False),
62+
sa.ForeignKeyConstraint(
63+
["props_id"],
64+
["props.id"],
65+
name=op.f("fk_props_allocation_props_id_props"),
66+
ondelete="CASCADE",
67+
),
68+
sa.ForeignKeyConstraint(
69+
["scene_id"],
70+
["scene.id"],
71+
name=op.f("fk_props_allocation_scene_id_scene"),
72+
ondelete="CASCADE",
73+
),
74+
sa.PrimaryKeyConstraint("id", name=op.f("pk_props_allocation")),
75+
)
76+
op.create_table(
77+
"scenery_allocation",
78+
sa.Column("id", sa.Integer(), nullable=False),
79+
sa.Column("scenery_id", sa.Integer(), nullable=False),
80+
sa.Column("scene_id", sa.Integer(), nullable=False),
81+
sa.ForeignKeyConstraint(
82+
["scene_id"],
83+
["scene.id"],
84+
name=op.f("fk_scenery_allocation_scene_id_scene"),
85+
ondelete="CASCADE",
86+
),
87+
sa.ForeignKeyConstraint(
88+
["scenery_id"],
89+
["scenery.id"],
90+
name=op.f("fk_scenery_allocation_scenery_id_scenery"),
91+
ondelete="CASCADE",
92+
),
93+
sa.PrimaryKeyConstraint("id", name=op.f("pk_scenery_allocation")),
94+
)
95+
# ### end Alembic commands ###
96+
97+
98+
def downgrade() -> None:
99+
# ### commands auto generated by Alembic - please adjust! ###
100+
op.drop_table("scenery_allocation")
101+
op.drop_table("props_allocation")
102+
op.drop_table("scenery")
103+
op.drop_table("props")
104+
op.drop_table("crew")
105+
# ### end Alembic commands ###

server/controllers/api/show/stage/crew.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
@ApiRoute("show/stage/crew", ApiVersion.V1)
1313
class CrewController(BaseAPIController):
14-
1514
@requires_show
1615
def get(self):
1716
current_show = self.get_current_show()

server/controllers/api/show/stage/props.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
@ApiRoute("show/stage/props", ApiVersion.V1)
1313
class PropsController(BaseAPIController):
14-
1514
@requires_show
1615
def get(self):
1716
current_show = self.get_current_show()

server/controllers/api/show/stage/scenery.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
@ApiRoute("show/stage/scenery", ApiVersion.V1)
1313
class SceneryController(BaseAPIController):
14-
1514
@requires_show
1615
def get(self):
1716
current_show = self.get_current_show()

server/models/show.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from models.mics import MicrophoneAllocation
1414
from models.script import ScriptLine
1515
from models.session import ShowSession
16+
from models.stage import Crew, Props, PropsAllocation, Scenery, SceneryAllocation
1617

1718

1819
class ShowScriptType(enum.IntEnum):

server/models/stage.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from sqlalchemy import ForeignKey
2-
from sqlalchemy.orm import relationship, Mapped, mapped_column
2+
from sqlalchemy.orm import Mapped, mapped_column, relationship
33

44
from models.models import db
55
from models.show import Scene, Show
@@ -23,9 +23,7 @@ class SceneryAllocation(db.Model):
2323
scenery_id: Mapped[int] = mapped_column(
2424
ForeignKey("scenery.id", ondelete="CASCADE")
2525
)
26-
scene_id: Mapped[int] = mapped_column(
27-
ForeignKey("scene.id", ondelete="CASCADE")
28-
)
26+
scene_id: Mapped[int] = mapped_column(ForeignKey("scene.id", ondelete="CASCADE"))
2927

3028
scenery: Mapped["Scenery"] = relationship(
3129
back_populates="scene_allocations",
@@ -41,12 +39,8 @@ class PropsAllocation(db.Model):
4139
__tablename__ = "props_allocation"
4240

4341
id: Mapped[int] = mapped_column(primary_key=True)
44-
props_id: Mapped[int] = mapped_column(
45-
ForeignKey("props.id", ondelete="CASCADE")
46-
)
47-
scene_id: Mapped[int] = mapped_column(
48-
ForeignKey("scene.id", ondelete="CASCADE")
49-
)
42+
props_id: Mapped[int] = mapped_column(ForeignKey("props.id", ondelete="CASCADE"))
43+
scene_id: Mapped[int] = mapped_column(ForeignKey("scene.id", ondelete="CASCADE"))
5044

5145
prop: Mapped["Props"] = relationship(
5246
back_populates="scene_allocations",

0 commit comments

Comments
 (0)