diff --git a/src/openg2p_portal_api/controllers/form_controller.py b/src/openg2p_portal_api/controllers/form_controller.py index d1bb1ca..627fd4e 100644 --- a/src/openg2p_portal_api/controllers/form_controller.py +++ b/src/openg2p_portal_api/controllers/form_controller.py @@ -35,10 +35,8 @@ def __init__(self, **kwargs): async def get_program_form(self, programid: int): response_dict = {} res = await ProgramORM.get_program_form(programid) - print(res) if res: form = res.form - print(form) if form: response_dict = { "id": form.id, diff --git a/src/openg2p_portal_api/models/orm/program_orm.py b/src/openg2p_portal_api/models/orm/program_orm.py index 1241e7a..245d53c 100644 --- a/src/openg2p_portal_api/models/orm/program_orm.py +++ b/src/openg2p_portal_api/models/orm/program_orm.py @@ -1,4 +1,4 @@ -from typing import List +from typing import List, Optional from openg2p_fastapi_common.context import dbengine from openg2p_fastapi_common.models import BaseORMModelWithId @@ -6,6 +6,9 @@ from sqlalchemy.ext.asyncio import async_sessionmaker from sqlalchemy.orm import Mapped, mapped_column, relationship, selectinload +from .formio_builder_orm import FormORM +from .program_membership_orm import ProgramMembershipORM + class ProgramORM(BaseORMModelWithId): __tablename__ = "g2p_program" @@ -14,12 +17,14 @@ class ProgramORM(BaseORMModelWithId): description: Mapped[str] = mapped_column(String()) is_multiple_form_submission: Mapped[str] = mapped_column() - membership = relationship("ProgramMembershipORM", back_populates="program") + membership: Mapped[Optional[List["ProgramMembershipORM"]]] = relationship( + back_populates="program" + ) self_service_portal_form: Mapped[int] = mapped_column( ForeignKey("formio_builder.id") ) - form = relationship("FormORM", back_populates="program") + form: Mapped[Optional[List["FormORM"]]] = relationship(back_populates="program") @classmethod async def get_all_programs(cls) -> List["ProgramORM"]: