From 500876ca021dfc19ea6d297b9a2ed7e3d07b7907 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=BCller?= Date: Tue, 27 Aug 2024 16:51:45 +0200 Subject: [PATCH] Fix software deletion from UI UI sends array of IDs as the payload, but backend expected object with files property. Files is not a good naming, so adjusted backend. UI however should always call the BFF, so some more work required. Not creating a test case for this issue before this bigger refactoring. --- goosebit/api/v1/software/requests.py | 6 +++--- goosebit/api/v1/software/routes.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/goosebit/api/v1/software/requests.py b/goosebit/api/v1/software/requests.py index 6a39756e..8ce35c27 100644 --- a/goosebit/api/v1/software/requests.py +++ b/goosebit/api/v1/software/requests.py @@ -1,5 +1,5 @@ -from pydantic import BaseModel +from pydantic import RootModel -class SoftwareDeleteRequest(BaseModel): - files: list[int] +class SoftwareDeleteRequest(RootModel[list[int]]): + pass diff --git a/goosebit/api/v1/software/routes.py b/goosebit/api/v1/software/routes.py index b36fb1ac..98d9bb13 100644 --- a/goosebit/api/v1/software/routes.py +++ b/goosebit/api/v1/software/routes.py @@ -26,7 +26,7 @@ async def software_get(_: Request) -> SoftwareResponse: ) async def software_delete(_: Request, config: SoftwareDeleteRequest) -> StatusResponse: success = False - for f_id in config.files: + for f_id in config.root: software = await Software.get_or_none(id=f_id) if software is None: