schema.py 736 B

12345678910111213141516171819202122232425262728293031323334
  1. from datetime import datetime
  2. from ninja import Field, ModelSchema, Schema
  3. from apps.projects.schema import ProjectSchema
  4. from apps.shared.schema.fields import SlugStr
  5. from glitchtip.schema import CamelSchema
  6. from .models import Team
  7. class TeamIn(Schema):
  8. slug: SlugStr
  9. class ProjectTeamSchema(CamelSchema, ModelSchema):
  10. """TeamSchema but without projects"""
  11. id: str
  12. created: datetime = Field(serialization_alias="dateCreated")
  13. is_member: bool
  14. member_count: int
  15. slug: SlugStr
  16. class Meta:
  17. model = Team
  18. fields = ["id", "slug"]
  19. class Config(CamelSchema.Config):
  20. coerce_numbers_to_str = True
  21. class TeamSchema(ProjectTeamSchema):
  22. projects: list[ProjectSchema] = []