feat: Projekt-Verwaltung verbessern — Archivieren, Loeschen, Wiederherstellen
Some checks failed
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-ai-compliance (push) Failing after 35s
CI / test-python-backend-compliance (push) Successful in 38s
CI / test-python-document-crawler (push) Successful in 24s
CI / test-python-dsms-gateway (push) Successful in 24s
Some checks failed
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-ai-compliance (push) Failing after 35s
CI / test-python-backend-compliance (push) Successful in 38s
CI / test-python-document-crawler (push) Successful in 24s
CI / test-python-dsms-gateway (push) Successful in 24s
- Backend: Restore-Endpoint (POST /projects/{id}/restore) und
Hard-Delete-Endpoint (DELETE /projects/{id}/permanent) hinzugefuegt
- Frontend: Dreistufiger Dialog (Archivieren / Endgueltig loeschen mit
Bestaetigungsdialog) statt einfachem Loeschen
- Archivierte Projekte aufklappbar in der Projektliste mit
Wiederherstellen-Button
- CustomerTypeSelector entfernt (redundant seit Multi-Projekt)
- Default tenantId von 'default' auf UUID geaendert (Backend-400-Fix)
- SQL-Cast :state::jsonb durch CAST(:state AS jsonb) ersetzt (SQLAlchemy-Fix)
- snake_case/camelCase-Mapping fuer Backend-Response (NaN-Datum-Fix)
- projectInfo wird beim Laden vom Backend geholt (Header zeigt Projektname)
- API-Client erzeugt sich on-demand (Race-Condition-Fix fuer Projektliste)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -179,7 +179,7 @@ async def create_project(
|
||||
db.execute(
|
||||
text("""
|
||||
INSERT INTO sdk_states (tenant_id, project_id, state, version, created_at, updated_at)
|
||||
VALUES (:tenant_id, :project_id, :state::jsonb, 1, NOW(), NOW())
|
||||
VALUES (:tenant_id, :project_id, CAST(:state AS jsonb), 1, NOW(), NOW())
|
||||
"""),
|
||||
{
|
||||
"tenant_id": tenant_id,
|
||||
@@ -298,3 +298,79 @@ async def archive_project(
|
||||
raise
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
|
||||
@router.post("/{project_id}/restore")
|
||||
async def restore_project(
|
||||
project_id: str,
|
||||
tenant_id: str = Depends(get_tenant_id),
|
||||
):
|
||||
"""Restore an archived project back to active."""
|
||||
db = SessionLocal()
|
||||
try:
|
||||
result = db.execute(
|
||||
text("""
|
||||
UPDATE compliance_projects
|
||||
SET status = 'active', archived_at = NULL, updated_at = NOW()
|
||||
WHERE id = :project_id AND tenant_id = :tenant_id AND status = 'archived'
|
||||
RETURNING id, tenant_id, name, description, customer_type, status,
|
||||
project_version, completion_percentage, created_at, updated_at
|
||||
"""),
|
||||
{"project_id": project_id, "tenant_id": tenant_id},
|
||||
)
|
||||
row = result.fetchone()
|
||||
if not row:
|
||||
raise HTTPException(status_code=404, detail="Project not found or not archived")
|
||||
db.commit()
|
||||
logger.info("Restored project %s for tenant %s", project_id, tenant_id)
|
||||
return _row_to_response(row)
|
||||
except HTTPException:
|
||||
raise
|
||||
except Exception:
|
||||
db.rollback()
|
||||
raise
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
|
||||
@router.delete("/{project_id}/permanent")
|
||||
async def permanently_delete_project(
|
||||
project_id: str,
|
||||
tenant_id: str = Depends(get_tenant_id),
|
||||
):
|
||||
"""Permanently delete a project and all associated data."""
|
||||
db = SessionLocal()
|
||||
try:
|
||||
# Verify project exists and belongs to tenant
|
||||
check = db.execute(
|
||||
text("""
|
||||
SELECT id FROM compliance_projects
|
||||
WHERE id = :project_id AND tenant_id = :tenant_id
|
||||
"""),
|
||||
{"project_id": project_id, "tenant_id": tenant_id},
|
||||
).fetchone()
|
||||
if not check:
|
||||
raise HTTPException(status_code=404, detail="Project not found")
|
||||
|
||||
# Delete sdk_states (CASCADE should handle this, but be explicit)
|
||||
db.execute(
|
||||
text("DELETE FROM sdk_states WHERE project_id = :project_id AND tenant_id = :tenant_id"),
|
||||
{"project_id": project_id, "tenant_id": tenant_id},
|
||||
)
|
||||
|
||||
# Delete the project itself
|
||||
db.execute(
|
||||
text("DELETE FROM compliance_projects WHERE id = :project_id AND tenant_id = :tenant_id"),
|
||||
{"project_id": project_id, "tenant_id": tenant_id},
|
||||
)
|
||||
|
||||
db.commit()
|
||||
logger.info("Permanently deleted project %s for tenant %s", project_id, tenant_id)
|
||||
return {"success": True, "id": project_id, "status": "deleted"}
|
||||
except HTTPException:
|
||||
raise
|
||||
except Exception:
|
||||
db.rollback()
|
||||
raise
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
Reference in New Issue
Block a user