Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions calendar_backend/models/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ class Direction(str, Enum):


class Room(BaseDbModel):
name: Mapped[int] = mapped_column(String, nullable=False, unique=True)
direction: Mapped[int] = mapped_column(DbEnum(Direction, native_enum=False), nullable=True)
building: Mapped[int] = mapped_column(String)
is_deleted: Mapped[int] = mapped_column(Boolean, default=False)
name: Mapped[str] = mapped_column(String, nullable=False, unique=True)
direction: Mapped[Direction] = mapped_column(DbEnum(Direction, native_enum=False), nullable=True)
building: Mapped[str] = mapped_column(String, nullable=True)
building_url: Mapped[str] = mapped_column(String, nullable=True)
is_deleted: Mapped[bool] = mapped_column(Boolean, default=False)

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


class Lecturer(BaseDbModel):
first_name: Mapped[int] = mapped_column(String, nullable=False)
middle_name: Mapped[int] = mapped_column(String, nullable=False)
last_name: Mapped[int] = mapped_column(String, nullable=False)
first_name: Mapped[str] = mapped_column(String, nullable=False)
middle_name: Mapped[str] = mapped_column(String, nullable=False)
last_name: Mapped[str] = mapped_column(String, nullable=False)
avatar_id: Mapped[int] = mapped_column(Integer, ForeignKey("photo.id"))
description: Mapped[int] = mapped_column(Text, nullable=True)
is_deleted: Mapped[int] = mapped_column(Boolean, default=False)
description: Mapped[str] = mapped_column(Text, nullable=True)
is_deleted: Mapped[bool] = mapped_column(Boolean, default=False)

avatar: Mapped[Photo] = relationship(
"Photo",
Expand Down
1 change: 1 addition & 0 deletions calendar_backend/routes/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class RoomGet(Base):
id: int
name: str
building: str | None
building_url: str | None
direction: str | None

def __repr__(self):
Expand Down
2 changes: 2 additions & 0 deletions calendar_backend/routes/models/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
class RoomPatch(Base):
name: str | None
building: str | None
building_url: str | None
direction: Direction | None

def __repr__(self):
Expand All @@ -15,6 +16,7 @@ def __repr__(self):
class RoomPost(Base):
name: str
building: str | None
building_url: str | None
direction: Direction | None


Expand Down
23 changes: 23 additions & 0 deletions migrations/versions/3948c45f9977_building_url.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""Building url

Revision ID: 3948c45f9977
Revises: 63263ee9e08e
Create Date: 2023-03-20 16:42:54.345727

"""
from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision = '3948c45f9977'
down_revision = '63263ee9e08e'
branch_labels = None
depends_on = None


def upgrade():
op.add_column('room', sa.Column('building_url', sa.String(), nullable=True))


def downgrade():
op.drop_column('room', 'building_url')