Skip to content

Commit 94f39b2

Browse files
authored
Building url (#87)
1 parent 0913374 commit 94f39b2

File tree

4 files changed

+36
-9
lines changed

4 files changed

+36
-9
lines changed

calendar_backend/models/db.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ class Direction(str, Enum):
3232

3333

3434
class Room(BaseDbModel):
35-
name: Mapped[int] = mapped_column(String, nullable=False, unique=True)
36-
direction: Mapped[int] = mapped_column(DbEnum(Direction, native_enum=False), nullable=True)
37-
building: Mapped[int] = mapped_column(String)
38-
is_deleted: Mapped[int] = mapped_column(Boolean, default=False)
35+
name: Mapped[str] = mapped_column(String, nullable=False, unique=True)
36+
direction: Mapped[Direction] = mapped_column(DbEnum(Direction, native_enum=False), nullable=True)
37+
building: Mapped[str] = mapped_column(String, nullable=True)
38+
building_url: Mapped[str] = mapped_column(String, nullable=True)
39+
is_deleted: Mapped[bool] = mapped_column(Boolean, default=False)
3940

4041
events: Mapped[list[Event]] = relationship(
4142
"Event",
@@ -47,12 +48,12 @@ class Room(BaseDbModel):
4748

4849

4950
class Lecturer(BaseDbModel):
50-
first_name: Mapped[int] = mapped_column(String, nullable=False)
51-
middle_name: Mapped[int] = mapped_column(String, nullable=False)
52-
last_name: Mapped[int] = mapped_column(String, nullable=False)
51+
first_name: Mapped[str] = mapped_column(String, nullable=False)
52+
middle_name: Mapped[str] = mapped_column(String, nullable=False)
53+
last_name: Mapped[str] = mapped_column(String, nullable=False)
5354
avatar_id: Mapped[int] = mapped_column(Integer, ForeignKey("photo.id"))
54-
description: Mapped[int] = mapped_column(Text, nullable=True)
55-
is_deleted: Mapped[int] = mapped_column(Boolean, default=False)
55+
description: Mapped[str] = mapped_column(Text, nullable=True)
56+
is_deleted: Mapped[bool] = mapped_column(Boolean, default=False)
5657

5758
avatar: Mapped[Photo] = relationship(
5859
"Photo",

calendar_backend/routes/models/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class RoomGet(Base):
6161
id: int
6262
name: str
6363
building: str | None
64+
building_url: str | None
6465
direction: str | None
6566

6667
def __repr__(self):

calendar_backend/routes/models/room.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
class RoomPatch(Base):
77
name: str | None
88
building: str | None
9+
building_url: str | None
910
direction: Direction | None
1011

1112
def __repr__(self):
@@ -15,6 +16,7 @@ def __repr__(self):
1516
class RoomPost(Base):
1617
name: str
1718
building: str | None
19+
building_url: str | None
1820
direction: Direction | None
1921

2022

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""Building url
2+
3+
Revision ID: 3948c45f9977
4+
Revises: 63263ee9e08e
5+
Create Date: 2023-03-20 16:42:54.345727
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
11+
# revision identifiers, used by Alembic.
12+
revision = '3948c45f9977'
13+
down_revision = '63263ee9e08e'
14+
branch_labels = None
15+
depends_on = None
16+
17+
18+
def upgrade():
19+
op.add_column('room', sa.Column('building_url', sa.String(), nullable=True))
20+
21+
22+
def downgrade():
23+
op.drop_column('room', 'building_url')

0 commit comments

Comments
 (0)