Skip to content

Commit

Permalink
Add project soft delete
Browse files Browse the repository at this point in the history
  • Loading branch information
berrydenhartog committed Nov 11, 2024
1 parent 0bbb4af commit 1553757
Show file tree
Hide file tree
Showing 13 changed files with 285 additions and 67 deletions.
10 changes: 10 additions & 0 deletions amt/api/routes/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,16 @@ def find_requirement_tasks_by_measure_urn(system_card: SystemCard, measure_urn:
return requirement_tasks


@router.delete("/{project_id}")
async def delete_project(
request: Request,
project_id: int,
projects_service: Annotated[ProjectsService, Depends(ProjectsService)],
) -> HTMLResponse:
await projects_service.delete(project_id)
return templates.Redirect(request, "/algorithm-systems/")


@router.get("/{project_id}/measure/{measure_urn}")
async def get_measure(
request: Request,
Expand Down
62 changes: 41 additions & 21 deletions amt/locale/base.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 0001-01-01 00:00+0000\n"
"PO-Revision-Date: 0001-01-01 00:00+0000\n"
"POT-Creation-Date: 2024-11-11 13:37+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.15.0\n"
"Generated-By: Babel 2.16.0\n"

#: amt/api/ai_act_profile.py:24
msgid "Type"
Expand Down Expand Up @@ -324,10 +324,10 @@ msgid "Reviewing"
msgstr ""

#: amt/site/templates/macros/tasks.html.j2:32
#: amt/site/templates/projects/details_base.html.j2:29
#: amt/site/templates/projects/details_base.html.j2:55
#: amt/site/templates/projects/details_base.html.j2:84
#: amt/site/templates/projects/details_base.html.j2:107
#: amt/site/templates/projects/details_base.html.j2:74
#: amt/site/templates/projects/details_base.html.j2:100
#: amt/site/templates/projects/details_base.html.j2:129
#: amt/site/templates/projects/details_base.html.j2:152
msgid "Done"
msgstr ""

Expand Down Expand Up @@ -499,28 +499,56 @@ msgstr ""
msgid "Select group by"
msgstr ""

#: amt/site/templates/projects/details_base.html.j2:19
msgid "Delete algoritmic system"
msgstr ""

#: amt/site/templates/projects/details_base.html.j2:26
msgid "Are you sure you want to delete your algoritmic system "
msgstr ""

#: amt/site/templates/projects/details_base.html.j2:30
msgid ""
"Data will be stored for at least 45 days before permanent\n"
" deletion."
msgstr ""

#: amt/site/templates/projects/details_base.html.j2:39
#: amt/site/templates/projects/new.html.j2:132
msgid "Yes"
msgstr ""

#: amt/site/templates/projects/details_base.html.j2:44
#: amt/site/templates/projects/new.html.j2:142
msgid "No"
msgstr ""

#: amt/site/templates/projects/details_base.html.j2:57
msgid "Delete algorithm system"
msgstr ""

#: amt/site/templates/projects/details_base.html.j2:71
msgid "Does the algorithm meet the requirements?"
msgstr ""

#: amt/site/templates/projects/details_base.html.j2:51
#: amt/site/templates/projects/details_base.html.j2:105
#: amt/site/templates/projects/details_base.html.j2:96
#: amt/site/templates/projects/details_base.html.j2:150
msgid "To do"
msgstr ""

#: amt/site/templates/projects/details_base.html.j2:53
#: amt/site/templates/projects/details_base.html.j2:98
msgid "In progress"
msgstr ""

#: amt/site/templates/projects/details_base.html.j2:70
#: amt/site/templates/projects/details_base.html.j2:115
msgid "Go to all requirements"
msgstr ""

#: amt/site/templates/projects/details_base.html.j2:81
#: amt/site/templates/projects/details_base.html.j2:126
msgid "Which instruments are executed?"
msgstr ""

#: amt/site/templates/projects/details_base.html.j2:122
#: amt/site/templates/projects/details_base.html.j2:167
msgid "Go to all instruments"
msgstr ""

Expand Down Expand Up @@ -684,14 +712,6 @@ msgstr ""
msgid "Find your AI Act profile"
msgstr ""

#: amt/site/templates/projects/new.html.j2:132
msgid "Yes"
msgstr ""

#: amt/site/templates/projects/new.html.j2:142
msgid "No"
msgstr ""

#: amt/site/templates/projects/new.html.j2:151
msgid ""
"Overview of instruments for the responsible development, deployment, "
Expand Down
Binary file modified amt/locale/en_US/LC_MESSAGES/messages.mo
Binary file not shown.
60 changes: 40 additions & 20 deletions amt/locale/en_US/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 0001-01-01 00:00+0000\n"
"POT-Creation-Date: 2024-11-11 13:37+0000\n"
"PO-Revision-Date: 0001-01-01 00:00+0000\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: en_US\n"
Expand All @@ -16,7 +16,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.15.0\n"
"Generated-By: Babel 2.16.0\n"

#: amt/api/ai_act_profile.py:24
msgid "Type"
Expand Down Expand Up @@ -325,10 +325,10 @@ msgid "Reviewing"
msgstr ""

#: amt/site/templates/macros/tasks.html.j2:32
#: amt/site/templates/projects/details_base.html.j2:29
#: amt/site/templates/projects/details_base.html.j2:55
#: amt/site/templates/projects/details_base.html.j2:84
#: amt/site/templates/projects/details_base.html.j2:107
#: amt/site/templates/projects/details_base.html.j2:74
#: amt/site/templates/projects/details_base.html.j2:100
#: amt/site/templates/projects/details_base.html.j2:129
#: amt/site/templates/projects/details_base.html.j2:152
msgid "Done"
msgstr ""

Expand Down Expand Up @@ -500,28 +500,56 @@ msgstr ""
msgid "Select group by"
msgstr ""

#: amt/site/templates/projects/details_base.html.j2:19
msgid "Delete algoritmic system"
msgstr ""

#: amt/site/templates/projects/details_base.html.j2:26
msgid "Are you sure you want to delete your algoritmic system "
msgstr ""

#: amt/site/templates/projects/details_base.html.j2:30
msgid ""
"Data will be stored for at least 45 days before permanent\n"
" deletion."
msgstr ""

#: amt/site/templates/projects/details_base.html.j2:39
#: amt/site/templates/projects/new.html.j2:132
msgid "Yes"
msgstr ""

#: amt/site/templates/projects/details_base.html.j2:44
#: amt/site/templates/projects/new.html.j2:142
msgid "No"
msgstr ""

#: amt/site/templates/projects/details_base.html.j2:57
msgid "Delete algorithm system"
msgstr ""

#: amt/site/templates/projects/details_base.html.j2:71
msgid "Does the algorithm meet the requirements?"
msgstr ""

#: amt/site/templates/projects/details_base.html.j2:51
#: amt/site/templates/projects/details_base.html.j2:105
#: amt/site/templates/projects/details_base.html.j2:96
#: amt/site/templates/projects/details_base.html.j2:150
msgid "To do"
msgstr ""

#: amt/site/templates/projects/details_base.html.j2:53
#: amt/site/templates/projects/details_base.html.j2:98
msgid "In progress"
msgstr ""

#: amt/site/templates/projects/details_base.html.j2:70
#: amt/site/templates/projects/details_base.html.j2:115
msgid "Go to all requirements"
msgstr ""

#: amt/site/templates/projects/details_base.html.j2:81
#: amt/site/templates/projects/details_base.html.j2:126
msgid "Which instruments are executed?"
msgstr ""

#: amt/site/templates/projects/details_base.html.j2:122
#: amt/site/templates/projects/details_base.html.j2:167
msgid "Go to all instruments"
msgstr ""

Expand Down Expand Up @@ -685,14 +713,6 @@ msgstr ""
msgid "Find your AI Act profile"
msgstr ""

#: amt/site/templates/projects/new.html.j2:132
msgid "Yes"
msgstr ""

#: amt/site/templates/projects/new.html.j2:142
msgid "No"
msgstr ""

#: amt/site/templates/projects/new.html.j2:151
msgid ""
"Overview of instruments for the responsible development, deployment, "
Expand Down
Binary file modified amt/locale/nl_NL/LC_MESSAGES/messages.mo
Binary file not shown.
62 changes: 42 additions & 20 deletions amt/locale/nl_NL/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 0001-01-01 00:00+0000\n"
"POT-Creation-Date: 2024-11-11 13:37+0000\n"
"PO-Revision-Date: 0001-01-01 00:00+0000\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: nl_NL\n"
Expand All @@ -16,7 +16,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.15.0\n"
"Generated-By: Babel 2.16.0\n"

#: amt/api/ai_act_profile.py:24
msgid "Type"
Expand Down Expand Up @@ -333,10 +333,10 @@ msgid "Reviewing"
msgstr "Beoordelen"

#: amt/site/templates/macros/tasks.html.j2:32
#: amt/site/templates/projects/details_base.html.j2:29
#: amt/site/templates/projects/details_base.html.j2:55
#: amt/site/templates/projects/details_base.html.j2:84
#: amt/site/templates/projects/details_base.html.j2:107
#: amt/site/templates/projects/details_base.html.j2:74
#: amt/site/templates/projects/details_base.html.j2:100
#: amt/site/templates/projects/details_base.html.j2:129
#: amt/site/templates/projects/details_base.html.j2:152
msgid "Done"
msgstr "Afgerond"

Expand Down Expand Up @@ -524,28 +524,58 @@ msgstr "Groeperen op"
msgid "Select group by"
msgstr "Selecteer groepering"

#: amt/site/templates/projects/details_base.html.j2:19
msgid "Delete algoritmic system"
msgstr "Verwijder Algoritmesysteem"

#: amt/site/templates/projects/details_base.html.j2:26
msgid "Are you sure you want to delete your algoritmic system "
msgstr "Weet u zeker dat u uw algoritmische systeem wilt verwijderen "

#: amt/site/templates/projects/details_base.html.j2:30
msgid ""
"Data will be stored for at least 45 days before permanent\n"
" deletion."
msgstr ""
"gegevens worden minimaal 45 dagen bewaard voordat ze definitief worden\n"
" verwijderd."

#: amt/site/templates/projects/details_base.html.j2:39
#: amt/site/templates/projects/new.html.j2:132
msgid "Yes"
msgstr "Ja"

#: amt/site/templates/projects/details_base.html.j2:44
#: amt/site/templates/projects/new.html.j2:142
msgid "No"
msgstr "Nee"

#: amt/site/templates/projects/details_base.html.j2:57
msgid "Delete algorithm system"
msgstr "Verwijder Algoritmesysteem"

#: amt/site/templates/projects/details_base.html.j2:71
msgid "Does the algorithm meet the requirements?"
msgstr "Voldoet het algoritme aan de vereisten?"

#: amt/site/templates/projects/details_base.html.j2:51
#: amt/site/templates/projects/details_base.html.j2:105
#: amt/site/templates/projects/details_base.html.j2:96
#: amt/site/templates/projects/details_base.html.j2:150
msgid "To do"
msgstr "Te doen"

#: amt/site/templates/projects/details_base.html.j2:53
#: amt/site/templates/projects/details_base.html.j2:98
msgid "In progress"
msgstr "Onderhanden"

#: amt/site/templates/projects/details_base.html.j2:70
#: amt/site/templates/projects/details_base.html.j2:115
msgid "Go to all requirements"
msgstr "Ga naar alle Vereisten"

#: amt/site/templates/projects/details_base.html.j2:81
#: amt/site/templates/projects/details_base.html.j2:126
msgid "Which instruments are executed?"
msgstr "Welke instrumenten zijn uitgevoerd?"

#: amt/site/templates/projects/details_base.html.j2:122
#: amt/site/templates/projects/details_base.html.j2:167
msgid "Go to all instruments"
msgstr "Ga naar all instrumenten"

Expand Down Expand Up @@ -716,14 +746,6 @@ msgstr ""
msgid "Find your AI Act profile"
msgstr "Vind uw AI Act profiel"

#: amt/site/templates/projects/new.html.j2:132
msgid "Yes"
msgstr "Ja"

#: amt/site/templates/projects/new.html.j2:142
msgid "No"
msgstr "Nee"

#: amt/site/templates/projects/new.html.j2:151
msgid ""
"Overview of instruments for the responsible development, deployment, "
Expand Down
27 changes: 27 additions & 0 deletions amt/migrations/versions/6581a03aabec_add_deleted_at_to_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""add deleted_at to project
Revision ID: 6581a03aabec
Revises: 7f20f8562007
Create Date: 2024-11-01 10:29:58.930558
"""

from collections.abc import Sequence

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import sqlite

# revision identifiers, used by Alembic.
revision: str = "6581a03aabec"
down_revision: str | None = "7f20f8562007"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade() -> None:
op.add_column("project", sa.Column("deleted_at", sa.DateTime(), nullable=True))


def downgrade() -> None:
op.drop_column("project", "deleted_at")
1 change: 1 addition & 0 deletions amt/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class Project(Base):
lifecycle: Mapped[Lifecycles | None] = mapped_column(ENUM(Lifecycles, name="lifecycle"), nullable=True)
system_card_json: Mapped[dict[str, Any]] = mapped_column(JSON, default=dict)
last_edited: Mapped[datetime] = mapped_column(server_default=func.now(), onupdate=func.now(), nullable=False)
deleted_at: Mapped[datetime | None] = mapped_column(server_default=None, nullable=True)

def __init__(self, *args: Any, **kwargs: Any) -> None: # noqa: ANN401
system_card: SystemCard | None = kwargs.pop("system_card", None)
Expand Down
Loading

0 comments on commit 1553757

Please sign in to comment.