diff --git a/server/mergin/sync/db_events.py b/server/mergin/sync/db_events.py index 0b2681e4..b489861a 100644 --- a/server/mergin/sync/db_events.py +++ b/server/mergin/sync/db_events.py @@ -51,4 +51,5 @@ def register_events(): def remove_events(): event.remove(User, "before_delete", remove_user_references) + event.remove(Project, "before_delete", remove_project_storage) event.remove(db.session, "before_commit", check) diff --git a/server/mergin/sync/public_api_v2.yaml b/server/mergin/sync/public_api_v2.yaml index e612f5cf..0eae3ce7 100644 --- a/server/mergin/sync/public_api_v2.yaml +++ b/server/mergin/sync/public_api_v2.yaml @@ -9,7 +9,7 @@ tags: - name: project description: Mergin project paths: - /project/{id}: + /projects/{id}: delete: tags: - project @@ -27,8 +27,8 @@ paths: "404": $ref: "#/components/responses/NotFound" x-openapi-router-controller: mergin.sync.public_api_v2_controller - /project/{id}/scheduleDelete: - delete: + /projects/{id}/scheduleDelete: + post: tags: - project summary: Schedule project to delete diff --git a/server/mergin/tests/test_public_api_v2.py b/server/mergin/tests/test_public_api_v2.py index 986c94d4..2213ced4 100644 --- a/server/mergin/tests/test_public_api_v2.py +++ b/server/mergin/tests/test_public_api_v2.py @@ -10,11 +10,11 @@ def test_schedule_delete_project(client): project = Project.query.filter_by( workspace_id=test_workspace_id, name=test_project ).first() - response = client.delete(f"v2/project/{project.id}/scheduleDelete") + response = client.post(f"v2/projects/{project.id}/scheduleDelete") assert response.status_code == 204 updated = Project.query.get(project.id) assert updated.removed_at and updated.removed_by - response = client.delete(f"v2/project/{project.id}/scheduleDelete") + response = client.post(f"v2/projects/{project.id}/scheduleDelete") assert response.status_code == 404 @@ -22,10 +22,10 @@ def test_delete_project_now(client): project = Project.query.filter_by( workspace_id=test_workspace_id, name=test_project ).first() - response = client.delete(f"v2/project/{project.id}") + response = client.delete(f"v2/projects/{project.id}") assert response.status_code == 204 assert not Project.query.get(project.id) - response = client.delete(f"v2/project/{project.id}") + response = client.delete(f"v2/projects/{project.id}") assert response.status_code == 404 @@ -33,7 +33,7 @@ def test_delete_after_schedule(client): project = Project.query.filter_by( workspace_id=test_workspace_id, name=test_project ).first() - response = client.delete(f"v2/project/{project.id}/scheduleDelete") + response = client.post(f"v2/projects/{project.id}/scheduleDelete") assert response.status_code == 204 - response = client.delete(f"v2/project/{project.id}") + response = client.delete(f"v2/projects/{project.id}") assert response.status_code == 204