feat: get users includes org info

This commit is contained in:
Chris Milne 2026-06-03 09:38:54 +01:00
parent 7833386350
commit 8a9f03ee0b
3 changed files with 13 additions and 4 deletions

View file

@ -185,7 +185,7 @@ async def get_users(org_model: org_model_root_claim_query_dependency):
"""
Returns a list of the email addresses of all users of the organisation.
"""
return {"users": [user.email for user in org_model.user_rel]}
return {"users": [user.email for user in org_model.user_rel], "organisation": org_model}
@router.post("/user",
@ -313,7 +313,7 @@ async def get_contact(org_model: org_model_root_claim_query_dependency, contact_
address = ContactAddress.model_validate(contact_model)
contact_response = ContactModel.model_construct(**contact_model.__dict__, address=address)
return {"contact": contact_response}
return {"contact": contact_response, "organisation": org_model}
@router.patch("/contact",

View file

@ -17,13 +17,17 @@ from src.user.schemas import UserIDMixin
from src.organisation.constants import Status, ContactType
class OrgIDMixin(CustomBaseModel):
organisation_id: int = Field(gt=0)
class Questionnaire(CustomBaseModel):
question_one: Optional[str] = None
question_two: Optional[str] = None
question_three: Optional[str] = None
class OrgIDMixin(CustomBaseModel):
organisation_id: int = Field(gt=0)
class OrgSchema(CustomBaseModel):
id: int
name: str
class OrgPostOrgRequest(CustomBaseModel):
@ -84,6 +88,7 @@ class OrgPatchRootResponse(CustomBaseModel):
class OrgGetUserResponse(CustomBaseModel):
users: list[str]
organisation: OrgSchema
class OrgGetGroupResponse(CustomBaseModel):
groups: list[str]

View file

@ -159,6 +159,10 @@ async def test_get_org_users_success(client: AsyncClient):
assert len(data["users"]) == 1
assert data["users"][0] == "admin@test.com"
assert "organisation" in data
assert data["organisation"]["name"] == "Test Org"
assert data["organisation"]["id"] == 1
@pytest.mark.parametrize(
"query, expected_status",