@@ -32,14 +32,14 @@ def create_team(cls, dto: CreateTeamDTO, created_by_user_id: str) -> CreateTeamR
32
32
description = dto .description ,
33
33
poc_id = PyObjectId (dto .poc_id ) if dto .poc_id else None ,
34
34
created_by = PyObjectId (created_by_user_id ),
35
- updated_by = PyObjectId (created_by_user_id )
35
+ updated_by = PyObjectId (created_by_user_id ),
36
36
)
37
37
38
38
created_team = TeamRepository .create (team )
39
39
40
40
# Create user-team relationships
41
41
user_teams = []
42
-
42
+
43
43
# Add members to the team
44
44
if dto .member_ids :
45
45
for user_id in dto .member_ids :
@@ -48,18 +48,29 @@ def create_team(cls, dto: CreateTeamDTO, created_by_user_id: str) -> CreateTeamR
48
48
team_id = created_team .id ,
49
49
role_id = "1" ,
50
50
created_by = PyObjectId (created_by_user_id ),
51
- updated_by = PyObjectId (created_by_user_id )
51
+ updated_by = PyObjectId (created_by_user_id ),
52
52
)
53
53
user_teams .append (user_team )
54
54
55
+ # Add POC if not already in member_ids
56
+ if dto .poc_id and dto .poc_id not in dto .member_ids :
57
+ poc_user_team = UserTeamDetailsModel (
58
+ user_id = PyObjectId (dto .poc_id ),
59
+ team_id = created_team .id ,
60
+ role_id = "2" , # POC role
61
+ created_by = PyObjectId (created_by_user_id ),
62
+ updated_by = PyObjectId (created_by_user_id ),
63
+ )
64
+ user_teams .append (poc_user_team )
65
+
55
66
# Add creator if not already in member_ids
56
67
if created_by_user_id not in dto .member_ids :
57
68
creator_user_team = UserTeamDetailsModel (
58
69
user_id = PyObjectId (created_by_user_id ),
59
70
team_id = created_team .id ,
60
71
role_id = "1" ,
61
72
created_by = PyObjectId (created_by_user_id ),
62
- updated_by = PyObjectId (created_by_user_id )
73
+ updated_by = PyObjectId (created_by_user_id ),
63
74
)
64
75
user_teams .append (creator_user_team )
65
76
@@ -82,4 +93,4 @@ def create_team(cls, dto: CreateTeamDTO, created_by_user_id: str) -> CreateTeamR
82
93
return CreateTeamResponse (team = team_dto )
83
94
84
95
except Exception as e :
85
- raise ValueError (str (e ))
96
+ raise ValueError (str (e ))
0 commit comments