project.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. from datetime import datetime
  2. from pydantic import BaseModel
  3. class ProjectCreate(BaseModel):
  4. """Schema for creating a new project."""
  5. name: str
  6. description: str | None = None
  7. color: str | None = None
  8. target_count: int | None = None
  9. class ProjectUpdate(BaseModel):
  10. """Schema for updating a project."""
  11. name: str | None = None
  12. description: str | None = None
  13. color: str | None = None
  14. status: str | None = None # active, completed, archived
  15. target_count: int | None = None
  16. class ProjectStats(BaseModel):
  17. """Statistics for a project."""
  18. total_archives: int = 0
  19. completed_prints: int = 0
  20. failed_prints: int = 0
  21. queued_prints: int = 0
  22. in_progress_prints: int = 0
  23. total_print_time_hours: float = 0.0
  24. total_filament_grams: float = 0.0
  25. progress_percent: float | None = None # Based on target_count
  26. class ProjectResponse(BaseModel):
  27. """Schema for project response."""
  28. id: int
  29. name: str
  30. description: str | None
  31. color: str | None
  32. status: str
  33. target_count: int | None
  34. created_at: datetime
  35. updated_at: datetime
  36. stats: ProjectStats | None = None
  37. class Config:
  38. from_attributes = True
  39. class ArchivePreview(BaseModel):
  40. """Minimal archive data for project preview."""
  41. id: int
  42. print_name: str | None
  43. thumbnail_path: str | None
  44. status: str
  45. class ProjectListResponse(BaseModel):
  46. """Schema for project list item (lighter weight)."""
  47. id: int
  48. name: str
  49. description: str | None
  50. color: str | None
  51. status: str
  52. target_count: int | None
  53. created_at: datetime
  54. # Quick stats
  55. archive_count: int = 0
  56. queue_count: int = 0
  57. progress_percent: float | None = None
  58. # Preview of archives (up to 5)
  59. archives: list[ArchivePreview] = []
  60. class Config:
  61. from_attributes = True
  62. class BatchAddArchives(BaseModel):
  63. """Schema for batch adding archives to a project."""
  64. archive_ids: list[int]
  65. class BatchAddQueueItems(BaseModel):
  66. """Schema for batch adding queue items to a project."""
  67. queue_item_ids: list[int]