T02: companies + contacts + import/export + N:M + soft-delete + GDPR + FTS

- Company CRUD with soft-delete, FTS search (tsvector + GIN), filter, pagination
- Contact CRUD with N:M company linking via company_contacts
- CSV/XLSX export, CSV import with dry-run preview
- GDPR hard-delete with deletion_log
- Audit log on all mutations
- 27 new tests (24 ACs), 56 total tests pass
- Migration 0002: contacts, company_contacts, FTS search_tsv
- Fixed T01 tests: POST→201, PATCH→PUT compatibility
This commit is contained in:
leocrm-bot
2026-06-29 00:44:34 +02:00
parent 7a7daf8100
commit 6bf0746b94
21 changed files with 2518 additions and 125 deletions
+38 -6
View File
@@ -1,4 +1,4 @@
"""Company schema (minimal for cross-tenant test)."""
"""Company schemas — create, update, read, list, pagination, search, filter."""
from __future__ import annotations
@@ -7,17 +7,49 @@ from pydantic import BaseModel, Field
class CompanyCreate(BaseModel):
name: str = Field(..., min_length=1, max_length=100)
industry: str | None = None
phone: str | None = None
email: str | None = None
website: str | None = None
account_number: str | None = Field(None, max_length=40)
industry: str | None = Field(None, max_length=50)
phone: str | None = Field(None, max_length=30)
email: str | None = Field(None, max_length=255)
website: str | None = Field(None, max_length=500)
description: str | None = None
class CompanyUpdate(BaseModel):
name: str | None = Field(None, min_length=1, max_length=100)
account_number: str | None = Field(None, max_length=40)
industry: str | None = Field(None, max_length=50)
phone: str | None = Field(None, max_length=30)
email: str | None = Field(None, max_length=255)
website: str | None = Field(None, max_length=500)
description: str | None = None
class CompanyResponse(BaseModel):
id: str
name: str
account_number: str | None = None
industry: str | None = None
phone: str | None = None
email: str | None = None
annual_revenue: float | None = None
website: str | None = None
description: str | None = None
created_at: str | None = None
updated_at: str | None = None
class CompanyDetailResponse(CompanyResponse):
contacts: list[dict] = Field(default_factory=list)
class CompanyListResponse(BaseModel):
items: list[CompanyResponse]
total: int
page: int
page_size: int
class CompanyExportRequest(BaseModel):
format: str = Field("csv", pattern="^(csv|xlsx)$")
industry: str | None = None
search: str | None = None