Skip to content

Commit

Permalink
Merge pull request #5 from mkumar-02/main
Browse files Browse the repository at this point in the history
Imported ORM model
  • Loading branch information
mkumar-02 authored Oct 18, 2023
2 parents c8998bc + 96136d1 commit 7d900d3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 0 additions & 2 deletions src/openg2p_portal_api/controllers/form_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 8 additions & 3 deletions src/openg2p_portal_api/models/orm/program_orm.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
from typing import List
from typing import List, Optional

from openg2p_fastapi_common.context import dbengine
from openg2p_fastapi_common.models import BaseORMModelWithId
from sqlalchemy import ForeignKey, String, select
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"
Expand All @@ -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"]:
Expand Down

0 comments on commit 7d900d3

Please sign in to comment.