feat: get users includes org info
This commit is contained in:
parent
7833386350
commit
8a9f03ee0b
3 changed files with 13 additions and 4 deletions
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue