Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change data type of origem_unidade in Pydantic to Enum #132

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""

from datetime import date
from enum import Enum
from typing import List, Optional

from pydantic import BaseModel, ConfigDict, Field, EmailStr
Expand Down Expand Up @@ -69,6 +70,11 @@ def cpf_validate(input_cpf: str) -> str:
return input_cpf


class OrigemUnidadeEnum(str, Enum):
siape = "SIAPE"
siorg = "SIORG"


class ContribuicaoSchema(BaseModel):
__doc__ = Contribuicao.__doc__
model_config = ConfigDict(from_attributes=True)
Expand Down Expand Up @@ -218,7 +224,7 @@ class PlanoTrabalhoSchema(BaseModel):
__doc__ = PlanoTrabalho.__doc__
model_config = ConfigDict(from_attributes=True)

origem_unidade: str = Field(
origem_unidade: OrigemUnidadeEnum = Field(
title="Origem da unidade",
description=PlanoTrabalho.origem_unidade.comment,
)
Expand Down Expand Up @@ -420,7 +426,7 @@ def validate_meta_percentual(self) -> "EntregaSchema":
class PlanoEntregasSchema(BaseModel):
__doc__ = PlanoEntregas.__doc__
model_config = ConfigDict(from_attributes=True)
origem_unidade: str = Field(
origem_unidade: OrigemUnidadeEnum = Field(
title="Código do sistema da unidade",
description=PlanoEntregas.origem_unidade.comment,
)
Expand Down Expand Up @@ -511,7 +517,7 @@ def validate_avaliacao(value: int) -> int:
class ParticipanteSchema(BaseModel):
__doc__ = Participante.__doc__
model_config = ConfigDict(from_attributes=True)
origem_unidade: str = Field(
origem_unidade: OrigemUnidadeEnum = Field(
title="Código do sistema da unidade (SIAPE ou SIORG)",
description=Participante.origem_unidade.comment,
)
Expand Down Expand Up @@ -623,7 +629,7 @@ class UsersGetSchema(UsersInputSchema):
default=False,
description=Users.disabled.comment,
)
origem_unidade: str = Field(
origem_unidade: OrigemUnidadeEnum = Field(
title="Código do sistema da unidade (SIAPE ou SIORG)",
description=Users.origem_unidade.comment,
)
Expand Down