schema.py 668 B

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