26 lines
866 B
Python
26 lines
866 B
Python
![]() |
from typing import List
|
||
|
|
||
|
from .factory import ProjectSupervisorFactory, YearGroupProjectSupervisorsFactory
|
||
|
from ..app.dependencies import db
|
||
|
from ..app.project_supervisor.models import YearGroup
|
||
|
from ..app.base.mode import ModeGroups
|
||
|
|
||
|
|
||
|
def create_year_group(data: dict = None) -> YearGroup:
|
||
|
if data is None:
|
||
|
data = {'mode': ModeGroups.STATIONARY.value, 'name': '2022/2023'}
|
||
|
yg = YearGroup(**data)
|
||
|
db.session.add(yg)
|
||
|
db.session.commit()
|
||
|
return yg
|
||
|
|
||
|
|
||
|
def create_project_supervisors(yg: YearGroup, amount: int) -> List[ProjectSupervisorFactory]:
|
||
|
ps = [ProjectSupervisorFactory() for _ in range(amount)]
|
||
|
db.session.add_all(ps)
|
||
|
db.session.commit()
|
||
|
db.session.add_all(
|
||
|
[YearGroupProjectSupervisorsFactory(limit_group=3, year_group_id=yg.id, project_supervisor_id=p.id) for p in ps])
|
||
|
db.session.commit()
|
||
|
return ps
|