@@ -12,11 +12,15 @@ class WorkspaceRepository:
1212 def __init__ (self , session : AsyncSession ):
1313 self .session = session
1414
15- async def create (self , projectGroupIds : list [str ], workspace_data : WorkspaceCreate ) -> Workspace :
15+ async def create (
16+ self , projectGroupIds : list [str ], workspace_data : WorkspaceCreate
17+ ) -> Workspace :
1618 workspace = Workspace (** workspace_data .model_dump ())
1719 try :
18- if (workspace .tdeiProjectGroupId not in projectGroupIds ):
19- raise ValueError ("User does not have permissions to create a workspace in that project group." )
20+ if workspace .tdeiProjectGroupId not in projectGroupIds :
21+ raise ValueError (
22+ "User does not have permissions to create a workspace in that project group."
23+ )
2024
2125 self .session .add (workspace )
2226 await self .session .commit ()
@@ -28,8 +32,13 @@ async def create(self, projectGroupIds: list[str], workspace_data: WorkspaceCrea
2832 f"Workspace with ID { workspace_data .id } already exists"
2933 )
3034
31- async def get_by_id (self , projectGroupIds : list [str ], workspace_id : int ) -> Workspace :
32- query = select (Workspace ).where (Workspace .id == workspace_id and Workspace .tdeiProjectGroupId .in_ (projectGroupIds ))
35+ async def get_by_id (
36+ self , projectGroupIds : list [str ], workspace_id : int
37+ ) -> Workspace :
38+ query = select (Workspace ).where (
39+ Workspace .id == workspace_id
40+ and Workspace .tdeiProjectGroupId .in_ (projectGroupIds )
41+ )
3342 result = await self .session .execute (query )
3443 workspace = result .scalar_one_or_none ()
3544
@@ -38,16 +47,30 @@ async def get_by_id(self, projectGroupIds: list[str], workspace_id: int) -> Work
3847 return workspace
3948
4049 async def get_all (self , projectGroupIds : list [str ]) -> list [Workspace ]:
41- query = select (Workspace ).where (Workspace .tdeiProjectGroupId .in_ (projectGroupIds ))
50+ query = select (Workspace ).where (
51+ Workspace .tdeiProjectGroupId .in_ (projectGroupIds )
52+ )
4253 result = await self .session .execute (query )
4354 return list (result .scalars ().all ())
4455
45- async def update (self , projectGroupIds : list [str ], workspace_id : int , workspace_data : WorkspaceUpdate ) -> Workspace :
56+ async def update (
57+ self ,
58+ projectGroupIds : list [str ],
59+ workspace_id : int ,
60+ workspace_data : WorkspaceUpdate ,
61+ ) -> Workspace :
4662 update_data = workspace_data .model_dump (exclude_unset = True )
4763 if not update_data :
4864 raise ValueError ("No fields to update" )
4965
50- query = update (Workspace ).where (Workspace .id == workspace_id and Workspace .tdeiProjectGroupId .in_ (projectGroupIds )).values (** update_data )
66+ query = (
67+ update (Workspace )
68+ .where (
69+ Workspace .id == workspace_id
70+ and Workspace .tdeiProjectGroupId .in_ (projectGroupIds )
71+ )
72+ .values (** update_data )
73+ )
5174 result = await self .session .execute (query )
5275
5376 if result .rowcount == 0 :
@@ -57,7 +80,10 @@ async def update(self, projectGroupIds: list[str], workspace_id: int, workspace_
5780 return await self .get_by_id (projectGroupIds , workspace_id )
5881
5982 async def delete (self , projectGroupIds : list [str ], workspace_id : int ) -> None :
60- query = delete (Workspace ).where (Workspace .id == workspace_id and Workspace .tdeiProjectGroupId .in_ (projectGroupIds ))
83+ query = delete (Workspace ).where (
84+ Workspace .id == workspace_id
85+ and Workspace .tdeiProjectGroupId .in_ (projectGroupIds )
86+ )
6187 result = await self .session .execute (query )
6288
6389 if result .rowcount == 0 :
0 commit comments