Skip to content

Commit

Permalink
fix: add odk cred org schemas for db and pydantic
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Jan 23, 2024
1 parent c74855e commit c8244ac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/backend/app/db/db_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ class DbOrganisation(Base):
description = Column(String)
url = Column(String)
type = Column(Enum(OrganisationType), default=OrganisationType.FREE, nullable=False)
# subscription_tier = Column(Integer)
odk_central_url = Column(String)
odk_central_user = Column(String)
odk_central_password = Column(String)

managers = relationship(
DbUser,
Expand Down
12 changes: 11 additions & 1 deletion src/backend/app/organisations/organisation_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,17 @@ class OrganisationIn(BaseModel):
Form(None, description="Organisation description")
)
url: Optional[HttpUrl] = Field(Form(None, description="Organisation website URL"))
odk_central_url: Optional[HttpUrl] = Field(
Form(None, description="Default ODK Central URL")
)
odk_central_user: Optional[str] = Field(
Form(None, description="Default ODK Central User")
)
odk_central_password: Optional[str] = Field(
Form(None, description="Default ODK Central Password")
)

@field_validator("url", mode="after")
@field_validator("url", "odk_central_url", mode="after")
@classmethod
def convert_url_to_str(cls, value: HttpUrl) -> str:
"""Convert Pydantic Url type to string.
Expand Down Expand Up @@ -78,3 +87,4 @@ class OrganisationOut(BaseModel):
slug: Optional[str]
url: Optional[str]
type: OrganisationType
odk_central_url: Optional[str]

0 comments on commit c8244ac

Please sign in to comment.