responses.py 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. from datetime import datetime
  2. from enum import Enum
  3. from pydantic import UUID4, BaseModel, ConfigDict, EmailStr
  4. from app.schemas.objects import PlanningConstraints
  5. class BaseResponse(BaseModel):
  6. model_config = ConfigDict(from_attributes=True)
  7. class BaseObjectResponse(BaseResponse):
  8. id: UUID4
  9. created_at: datetime
  10. updated_at: datetime
  11. class AccessTokenResponse(BaseResponse):
  12. token_type: str
  13. access_token: str
  14. expires_at: int
  15. issued_at: int
  16. refresh_token: str
  17. refresh_token_expires_at: int
  18. refresh_token_issued_at: int
  19. # ---- Organization ----
  20. class OrganizationResponse(BaseResponse):
  21. id: str
  22. name: str
  23. class MembershipUserResponse(BaseResponse):
  24. id: str
  25. email: EmailStr
  26. name: str
  27. class OrganizationMembershipResponse(BaseResponse):
  28. user_id: str
  29. organization_id: str
  30. role: str
  31. user: MembershipUserResponse
  32. class OrganizationDetailResponse(OrganizationResponse):
  33. name: str
  34. memberships: list[OrganizationMembershipResponse] = []
  35. class UserOrganizationResponse(BaseResponse):
  36. organization: OrganizationResponse
  37. role: str
  38. class UserResponse(BaseResponse):
  39. id: str
  40. email: EmailStr
  41. name: str
  42. phone_number: str | None = None
  43. global_role: str
  44. organizations: list[UserOrganizationResponse] = []
  45. must_change_password: bool
  46. class CommissionResponse(BaseObjectResponse):
  47. name: str
  48. templates_id: list[UUID4] = []
  49. members_id: list[UUID4] = []
  50. class VolunteerGroupResponse(BaseObjectResponse):
  51. name: str
  52. color: str | None = None
  53. volunteers_id: list[UUID4] = []
  54. class VolunteerResponse(BaseObjectResponse):
  55. name: str
  56. surname: str
  57. email: str
  58. phone_number: str
  59. automatic_sms: bool
  60. slots_id: list[UUID4] = []
  61. groups_id: list[str] = []
  62. comment: str
  63. class SlotResponse(BaseObjectResponse):
  64. title: str
  65. starting_time: datetime
  66. ending_time: datetime
  67. required_volunteers: int
  68. volunteers_id: list[str] = []
  69. template_id: UUID4 | None
  70. class SMSResponse(BaseObjectResponse):
  71. volunteer_id: UUID4 | None
  72. content: str
  73. phone_number: str
  74. sending_time: datetime
  75. send_time: datetime | None
  76. class TemplateResponse(BaseObjectResponse):
  77. title: str
  78. description: str
  79. place: str
  80. responsible_override: str | None = None
  81. commission_id: str | None = None
  82. tags_id: list[UUID4] = []
  83. comment: str
  84. class TagResponse(BaseObjectResponse):
  85. title: str
  86. templates_id: list[str] = []
  87. class ProjectResponse(BaseObjectResponse):
  88. name: str
  89. organization_id: str
  90. volunteers: list[VolunteerResponse]
  91. sms: list[SMSResponse]
  92. slots: list[SlotResponse]
  93. tags: list[TagResponse]
  94. templates: list[TemplateResponse]
  95. groups: list[VolunteerGroupResponse] = []
  96. commissions: list[CommissionResponse] = []
  97. constraints: PlanningConstraints
  98. is_public: bool
  99. class ProjectListResponse(BaseResponse):
  100. id: UUID4
  101. created_at: datetime
  102. updated_at: datetime
  103. name: str
  104. organization_id: str
  105. is_public: bool
  106. class EnumServerStatus(Enum):
  107. ACTIVE = "active"
  108. INVALID = "invalid (heartbeat missing)"
  109. INACTIVE = "inactive (stale)"
  110. class SMSServerStatus(BaseResponse):
  111. updated_at: datetime
  112. host: str
  113. user_agent: str
  114. message: EnumServerStatus