organization.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. """
  2. Pydantic schemas for Organization model.
  3. """
  4. from datetime import datetime
  5. from pydantic import BaseModel, EmailStr
  6. class OrganizationBase(BaseModel):
  7. """Base organization schema."""
  8. name: str
  9. contact_name: str | None = None
  10. contact_email: EmailStr
  11. contact_phone: str | None = None
  12. class OrganizationCreate(OrganizationBase):
  13. """Schema for creating an organization."""
  14. wifi_enabled: bool = False
  15. ble_enabled: bool = False
  16. android_enabled: bool = False
  17. class OrganizationUpdate(BaseModel):
  18. """Schema for updating an organization."""
  19. name: str | None = None
  20. contact_name: str | None = None
  21. contact_email: EmailStr | None = None
  22. contact_phone: str | None = None
  23. wifi_enabled: bool | None = None
  24. ble_enabled: bool | None = None
  25. android_enabled: bool | None = None
  26. status: str | None = None
  27. notes: str | None = None
  28. class OrganizationResponse(OrganizationBase):
  29. """Schema for organization response."""
  30. id: int
  31. wifi_enabled: bool
  32. ble_enabled: bool
  33. android_enabled: bool
  34. status: str
  35. notes: str | None
  36. created_at: datetime
  37. class Config:
  38. from_attributes = True
  39. class OrganizationListResponse(BaseModel):
  40. """Schema for list of organizations."""
  41. organizations: list[OrganizationResponse]
  42. total: int