From c8244acf2daee917e5e032171176a6eac04fe0c6 Mon Sep 17 00:00:00 2001 From: spwoodcock Date: Tue, 23 Jan 2024 10:15:15 +0000 Subject: [PATCH] fix: add odk cred org schemas for db and pydantic --- src/backend/app/db/db_models.py | 4 +++- .../app/organisations/organisation_schemas.py | 12 +++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/backend/app/db/db_models.py b/src/backend/app/db/db_models.py index cf14d49d2b..5ef22dbef0 100644 --- a/src/backend/app/db/db_models.py +++ b/src/backend/app/db/db_models.py @@ -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, diff --git a/src/backend/app/organisations/organisation_schemas.py b/src/backend/app/organisations/organisation_schemas.py index 26f76af45e..a81e5a6696 100644 --- a/src/backend/app/organisations/organisation_schemas.py +++ b/src/backend/app/organisations/organisation_schemas.py @@ -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. @@ -78,3 +87,4 @@ class OrganisationOut(BaseModel): slug: Optional[str] url: Optional[str] type: OrganisationType + odk_central_url: Optional[str]