Skip to content

Commit

Permalink
feat: Add archived flag for t4c instances
Browse files Browse the repository at this point in the history
  • Loading branch information
dominik003 committed Sep 11, 2023
1 parent bc2be46 commit 91a4b2a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# SPDX-FileCopyrightText: Copyright DB Netz AG and the capella-collab-manager contributors
# SPDX-License-Identifier: Apache-2.0

"""Add archive flag
Revision ID: f7bf9456cfc9
Revises: d8cf851562cd
Create Date: 2023-08-28 08:57:22.931913
"""
import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "f7bf9456cfc9"
down_revision = "d8cf851562cd"
branch_labels = None
depends_on = None


def upgrade():
op.add_column(
"t4c_instances", sa.Column("is_archived", sa.Boolean(), nullable=True)
)

op.get_bind().execute(
sa.text("UPDATE t4c_instances SET is_archived=false")
)

op.alter_column(
"t4c_instances",
"is_archived",
existing_type=sa.BOOLEAN(),
nullable=False,
)
5 changes: 5 additions & 0 deletions backend/capellacollab/settings/modelsources/t4c/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ class DatabaseT4CInstance(database.Base):
back_populates="instance", cascade="all, delete"
)

is_archived: orm.Mapped[bool] = orm.mapped_column(default=False)


def port_validator(value: int | None) -> int | None:
if not value:
Expand Down Expand Up @@ -123,6 +125,7 @@ class PatchT4CInstance(pydantic.BaseModel):
password: str | None = None
protocol: Protocol | None = None
version_id: int | None = None
is_archived: bool | None = None

_validate_rest_api_url = pydantic.field_validator("rest_api")(
validate_rest_api_url
Expand All @@ -138,9 +141,11 @@ class T4CInstanceComplete(T4CInstanceBase):


class CreateT4CInstance(T4CInstanceComplete):
is_archived: bool | None = None
password: str


class T4CInstance(T4CInstanceComplete):
id: int
version: tools_models.ToolVersionBase
is_archived: bool
1 change: 1 addition & 0 deletions frontend/src/app/services/settings/t4c-instance.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export type BaseT4CInstance = {
username: string;
password: string;
protocol: Protocol;
is_archived: boolean;
};

export type NewT4CInstance = BaseT4CInstance & {
Expand Down

0 comments on commit 91a4b2a

Please sign in to comment.