feat: get org response mirrors get user orgs structure
All checks were successful
ci / lint_and_test (push) Successful in 13s
All checks were successful
ci / lint_and_test (push) Successful in 13s
This commit is contained in:
parent
939abaefe9
commit
3b82025abb
5 changed files with 52 additions and 46 deletions
|
|
@ -92,17 +92,26 @@ async def get_org_by_id(org_model: org_model_root_claim_query_dependency):
|
|||
Returns organisation details including key member email addresses
|
||||
"""
|
||||
response = {
|
||||
"id": org_model.id,
|
||||
"organisation_id": org_model.id,
|
||||
"name": org_model.name,
|
||||
"status": org_model.status,
|
||||
"owner_contact": org_model.owner_contact_rel.email,
|
||||
"billing_contact": org_model.billing_contact_rel.email,
|
||||
"security_contact": org_model.security_contact_rel.email,
|
||||
"root_user": org_model.root_user_email,
|
||||
"intake_questionnaire": org_model.intake_questionnaire,
|
||||
"root_user_email": org_model.root_user_email,
|
||||
"billing_contact": {
|
||||
"id": org_model.billing_contact_id,
|
||||
"email": org_model.billing_contact_rel.email,
|
||||
},
|
||||
"owner_contact": {
|
||||
"id": org_model.owner_contact_id,
|
||||
"email": org_model.owner_contact_rel.email,
|
||||
},
|
||||
"security_contact": {
|
||||
"id": org_model.security_contact_id,
|
||||
"email": org_model.security_contact_rel.email,
|
||||
},
|
||||
}
|
||||
|
||||
return response
|
||||
return {"organisations": [response]}
|
||||
|
||||
|
||||
@router.post(
|
||||
|
|
|
|||
|
|
@ -22,11 +22,27 @@ class Questionnaire(CustomBaseModel):
|
|||
question_three: Optional[str] = None
|
||||
|
||||
|
||||
class OrgSchema(CustomBaseModel):
|
||||
class OrgSummary(CustomBaseModel):
|
||||
id: int
|
||||
name: str
|
||||
|
||||
|
||||
class ContactSummary(CustomBaseModel):
|
||||
id: int
|
||||
email: Optional[EmailStr] = None
|
||||
|
||||
|
||||
class OrgSchema(OrgIDMixin):
|
||||
name: str
|
||||
status: Status
|
||||
root_user_email: EmailStr
|
||||
intake_questionnaire: Optional[Questionnaire] = None
|
||||
|
||||
billing_contact: ContactSummary
|
||||
owner_contact: ContactSummary
|
||||
security_contact: ContactSummary
|
||||
|
||||
|
||||
class OrgPostOrgRequest(CustomBaseModel):
|
||||
name: str
|
||||
intake_questionnaire: Optional[Questionnaire] = None
|
||||
|
|
@ -93,7 +109,7 @@ class OrgPatchRootResponse(CustomBaseModel):
|
|||
|
||||
class OrgGetUserResponse(CustomBaseModel):
|
||||
users: list[dict[str, str | int]]
|
||||
organisation: OrgSchema
|
||||
organisation: OrgSummary
|
||||
|
||||
|
||||
class OrgGetGroupResponse(CustomBaseModel):
|
||||
|
|
@ -104,22 +120,15 @@ class OrgGetContactResponse(CustomBaseModel):
|
|||
model_config = ConfigDict(from_attributes=True, extra="ignore")
|
||||
|
||||
contact: ContactModel
|
||||
organisation: OrgSchema
|
||||
organisation: OrgSummary
|
||||
|
||||
|
||||
class OrgPatchContactResponse(CustomBaseModel):
|
||||
model_config = ConfigDict(from_attributes=True, extra="ignore")
|
||||
|
||||
contact: ContactModel
|
||||
organisation: OrgSchema
|
||||
organisation: OrgSummary
|
||||
|
||||
|
||||
class OrgGetOrgResponse(CustomBaseModel):
|
||||
id: int
|
||||
name: str
|
||||
status: Status
|
||||
root_user: Optional[str] = None
|
||||
owner_contact: Optional[str] = None
|
||||
billing_contact: Optional[str] = None
|
||||
security_contact: Optional[str] = None
|
||||
intake_questionnaire: Optional[Questionnaire] = None
|
||||
organisations: list[OrgSchema]
|
||||
|
|
|
|||
|
|
@ -5,27 +5,10 @@ Pydantic models for the user module
|
|||
from typing import Optional
|
||||
from pydantic import EmailStr
|
||||
|
||||
from src.organisation.constants import Status
|
||||
from src.organisation.schemas import Questionnaire
|
||||
from src.organisation.schemas import OrgSchema
|
||||
from src.schemas import CustomBaseModel, OrgIDMixin
|
||||
|
||||
|
||||
class ContactModel(CustomBaseModel):
|
||||
id: int
|
||||
email: Optional[EmailStr] = None
|
||||
|
||||
|
||||
class OrgSchema(OrgIDMixin):
|
||||
name: str
|
||||
status: Status
|
||||
root_user_email: EmailStr
|
||||
intake_questionnaire: Optional[Questionnaire] = None
|
||||
|
||||
billing_contact: ContactModel
|
||||
owner_contact: ContactModel
|
||||
security_contact: ContactModel
|
||||
|
||||
|
||||
class OIDCClaims(CustomBaseModel):
|
||||
exp: int
|
||||
iat: int
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue