Skip to content

Commit

Permalink
Feat: add user simple schema in structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Rotheem committed Jan 16, 2025
1 parent fc51084 commit e629886
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
17 changes: 17 additions & 0 deletions app/core/myeclpay/cruds_myeclpay.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.orm import selectinload

from app.core import schemas_core
from app.core.myeclpay import models_myeclpay, schemas_myeclpay
from app.core.myeclpay.types_myeclpay import (
TransactionStatus,
Expand Down Expand Up @@ -116,6 +117,14 @@ async def get_structures(
membership=structure.membership,
manager_user_id=structure.manager_user_id,
id=structure.id,
manager_user=schemas_core.CoreUserSimple(
id=structure.manager_user.id,
firstname=structure.manager_user.firstname,
name=structure.manager_user.name,
nickname=structure.manager_user.nickname,
account_type=structure.manager_user.account_type,
school_id=structure.manager_user.school_id,
),
)
for structure in result.scalars().all()
]
Expand All @@ -142,6 +151,14 @@ async def get_structure_by_id(
membership=structure.membership,
manager_user_id=structure.manager_user_id,
id=structure.id,
manager_user=schemas_core.CoreUserSimple(
id=structure.manager_user.id,
firstname=structure.manager_user.firstname,
name=structure.manager_user.name,
nickname=structure.manager_user.nickname,
account_type=structure.manager_user.account_type,
school_id=structure.manager_user.school_id,
),
)
if structure
else None
Expand Down
2 changes: 2 additions & 0 deletions app/core/myeclpay/models_myeclpay.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ class Structure(Base):
membership: Mapped[AvailableAssociationMembership | None]
manager_user_id: Mapped[str] = mapped_column(ForeignKey("core_user.id"))

manager_user: Mapped[models_core.CoreUser] = relationship(init=False, lazy="joined")


class StructureManagerTransfert(Base):
__tablename__ = "myeclpay_structure_manager_transfer"
Expand Down
1 change: 1 addition & 0 deletions app/core/myeclpay/schemas_myeclpay.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class StructureBase(BaseModel):

class Structure(StructureBase):
id: UUID
manager_user: schemas_core.CoreUserSimple


class StructureUpdate(BaseModel):
Expand Down

0 comments on commit e629886

Please sign in to comment.