From 5a93ef439cb19977b363b37c67f5d00d7ced8750 Mon Sep 17 00:00:00 2001 From: dominik003 Date: Mon, 28 Aug 2023 11:15:51 +0200 Subject: [PATCH] feat: Add archived flag for t4c instances --- .../versions/f7bf9456cfc9_add_archive_flag.py | 35 +++++++++++++++++++ .../settings/modelsources/t4c/models.py | 5 +++ .../services/settings/t4c-instance.service.ts | 1 + 3 files changed, 41 insertions(+) create mode 100644 backend/capellacollab/alembic/versions/f7bf9456cfc9_add_archive_flag.py diff --git a/backend/capellacollab/alembic/versions/f7bf9456cfc9_add_archive_flag.py b/backend/capellacollab/alembic/versions/f7bf9456cfc9_add_archive_flag.py new file mode 100644 index 0000000000..af35c1fd3b --- /dev/null +++ b/backend/capellacollab/alembic/versions/f7bf9456cfc9_add_archive_flag.py @@ -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, + ) diff --git a/backend/capellacollab/settings/modelsources/t4c/models.py b/backend/capellacollab/settings/modelsources/t4c/models.py index d89ae1458b..fc9ff63f14 100644 --- a/backend/capellacollab/settings/modelsources/t4c/models.py +++ b/backend/capellacollab/settings/modelsources/t4c/models.py @@ -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: @@ -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 @@ -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 diff --git a/frontend/src/app/services/settings/t4c-instance.service.ts b/frontend/src/app/services/settings/t4c-instance.service.ts index 547fd4e94b..5c2588c9fa 100644 --- a/frontend/src/app/services/settings/t4c-instance.service.ts +++ b/frontend/src/app/services/settings/t4c-instance.service.ts @@ -22,6 +22,7 @@ export type BaseT4CInstance = { username: string; password: string; protocol: Protocol; + is_archived: boolean; }; export type NewT4CInstance = BaseT4CInstance & {