e62ece1c06
- FastAPI app with CORS, lifespan handlers - Pydantic Settings config (DB, Redis, CORS, SMTP, JWT, Rentman) - SQLAlchemy async engine + session (DeclarativeBase) - 6 DB models: EquipmentCache, RentalRequest, RentalRequestItem, Contact, AdminUser, SyncLog - Pydantic schemas: EquipmentItem, EquipmentDetail, PaginatedEquipment, ContactCreate, ContactResponse - Redis cache helper: set/get/delete_pattern, rate limiting, equipment key builders - Equipment router: list (search/category/sort/pagination), detail, categories – all cached - Contact router: POST with Pydantic validation + rate limiting (5/min) - Health router: GET /api/health with DB + Redis status - 28 pytest tests (all pass, 90% coverage) - Dockerfile, requirements.txt, pytest.ini, test_report.md
28 lines
859 B
Python
28 lines
859 B
Python
"""Pydantic schemas for contact form."""
|
|
|
|
from pydantic import BaseModel, EmailStr, Field, model_validator
|
|
|
|
|
|
class ContactCreate(BaseModel):
|
|
"""Contact form input schema."""
|
|
|
|
name: str = Field(..., min_length=1, max_length=255)
|
|
email: EmailStr
|
|
phone: str | None = Field(None, max_length=64)
|
|
message: str = Field(..., min_length=1, max_length=5000)
|
|
privacy_consent: bool = Field(..., description="Must be True")
|
|
|
|
@model_validator(mode="after")
|
|
def consent_must_be_true(self) -> "ContactCreate":
|
|
"""Reject submissions where privacy_consent is not True."""
|
|
if not self.privacy_consent:
|
|
raise ValueError("privacy_consent must be True")
|
|
return self
|
|
|
|
|
|
class ContactResponse(BaseModel):
|
|
"""Contact form response."""
|
|
|
|
success: bool
|
|
message: str = "Kontakt-Anfrage erfolgreich gesendet."
|