feat: more ids returned on endpoints
All checks were successful
ci / lint_and_test (push) Successful in 14s
All checks were successful
ci / lint_and_test (push) Successful in 14s
Issue: #23
This commit is contained in:
parent
5a433dfe41
commit
294baadcb7
7 changed files with 90 additions and 19 deletions
|
|
@ -314,7 +314,10 @@ async def add_user_to_org(
|
|||
raise ConflictException(message="User already a part of this organisation")
|
||||
org_model.user_rel.append(user_model)
|
||||
db.flush()
|
||||
response = {"users": [user.email for user in org_model.user_rel]}
|
||||
response = {
|
||||
"organisation": org_model,
|
||||
"users": [{"id": user.id, "email": user.email} for user in org_model.user_rel],
|
||||
}
|
||||
db.commit()
|
||||
return response
|
||||
|
||||
|
|
@ -437,7 +440,12 @@ async def get_org_groups(org_model: org_model_root_claim_query_dependency):
|
|||
"""
|
||||
Returns a list of the names of all IAM groups created by the organisation.
|
||||
"""
|
||||
return {"groups": [group.name for group in org_model.group_rel]}
|
||||
return {
|
||||
"organisation": org_model,
|
||||
"groups": [
|
||||
{"id": group.id, "name": group.name} for group in org_model.group_rel
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
@router.delete(
|
||||
|
|
|
|||
|
|
@ -10,7 +10,14 @@ from typing import Optional
|
|||
|
||||
from pydantic import EmailStr, ConfigDict
|
||||
|
||||
from src.schemas import CustomBaseModel, OrgIDMixin, UserIDMixin
|
||||
from src.schemas import (
|
||||
CustomBaseModel,
|
||||
OrgIDMixin,
|
||||
UserIDMixin,
|
||||
GroupSummary,
|
||||
OrgSummary,
|
||||
UserSummary,
|
||||
)
|
||||
from src.contact.schemas import ContactModel
|
||||
|
||||
from src.organisation.constants import Status, ContactType
|
||||
|
|
@ -22,11 +29,6 @@ class Questionnaire(CustomBaseModel):
|
|||
question_three: Optional[str] = None
|
||||
|
||||
|
||||
class OrgSummary(CustomBaseModel):
|
||||
id: int
|
||||
name: str
|
||||
|
||||
|
||||
class ContactSummary(CustomBaseModel):
|
||||
id: int
|
||||
email: Optional[EmailStr] = None
|
||||
|
|
@ -49,6 +51,7 @@ class OrgPostOrgRequest(CustomBaseModel):
|
|||
|
||||
|
||||
class OrgPostOrgResponse(CustomBaseModel):
|
||||
id: int
|
||||
name: str
|
||||
status: Status
|
||||
|
||||
|
|
@ -59,6 +62,7 @@ class OrgPatchQuestionnaireRequest(OrgIDMixin):
|
|||
|
||||
|
||||
class OrgPatchQuestionnaireResponse(CustomBaseModel):
|
||||
id: int
|
||||
name: str
|
||||
intake_questionnaire: Questionnaire
|
||||
status: Status
|
||||
|
|
@ -69,6 +73,7 @@ class OrgPatchStatusRequest(OrgIDMixin):
|
|||
|
||||
|
||||
class OrgPatchStatusResponse(CustomBaseModel):
|
||||
id: int
|
||||
name: str
|
||||
status: Status
|
||||
|
||||
|
|
@ -95,7 +100,8 @@ class OrgPostUserRequest(OrgIDMixin, UserIDMixin):
|
|||
|
||||
|
||||
class OrgPostUserResponse(CustomBaseModel):
|
||||
users: list[str]
|
||||
organisation: OrgSummary
|
||||
users: list[UserSummary]
|
||||
|
||||
|
||||
class OrgPatchRootRequest(OrgIDMixin, UserIDMixin):
|
||||
|
|
@ -113,7 +119,8 @@ class OrgGetUserResponse(CustomBaseModel):
|
|||
|
||||
|
||||
class OrgGetGroupResponse(CustomBaseModel):
|
||||
groups: list[str]
|
||||
organisation: OrgSummary
|
||||
groups: list[GroupSummary]
|
||||
|
||||
|
||||
class OrgGetContactResponse(CustomBaseModel):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue