|
9 | 9 | from collections import defaultdict |
10 | 10 | from dataclasses import dataclass |
11 | 11 | from enum import Enum |
12 | | -from typing import Any, ClassVar, Dict, Iterator, List, Optional, Set |
| 12 | +from typing import Any, Dict, Iterator, List, Optional, Set |
13 | 13 |
|
14 | 14 | from lbox.exceptions import ( |
15 | 15 | InvalidQueryError, |
@@ -109,14 +109,6 @@ class UserGroup(BaseModel): |
109 | 109 | UserGroups. Users with any organization role will be rejected. |
110 | 110 | """ |
111 | 111 |
|
112 | | - # UserGroup roles that cannot be assigned (from Labelbox business rules) |
113 | | - UNASSIGNABLE_USERGROUP_ROLES: ClassVar[Set[str]] = { |
114 | | - "ADMIN", |
115 | | - "DATA_ADMIN", |
116 | | - "READ-ONLY_ADMIN", |
117 | | - "TENANT_ADMIN", |
118 | | - } |
119 | | - |
120 | 112 | id: str |
121 | 113 | name: str |
122 | 114 | color: UserGroupColor |
@@ -579,51 +571,22 @@ def _build_user_roles( |
579 | 571 |
|
580 | 572 | Returns: |
581 | 573 | List of user role dictionaries for the GraphQL mutation. |
582 | | -
|
583 | | - Raises: |
584 | | - ValueError: If any UserGroup roles are invalid/unassignable. |
585 | 574 | """ |
586 | 575 | user_roles: List[Dict[str, str]] = [] |
587 | | - invalid_roles = [] |
588 | 576 |
|
589 | 577 | # Add legacy users with default role |
590 | 578 | for user in self.users: |
591 | 579 | if user in eligible_users and self.default_role is not None: |
592 | | - if ( |
593 | | - self.default_role.name.upper() |
594 | | - in self.UNASSIGNABLE_USERGROUP_ROLES |
595 | | - ): |
596 | | - invalid_roles.append( |
597 | | - f"Default role '{self.default_role.name}' cannot be assigned in UserGroups" |
598 | | - ) |
599 | | - else: |
600 | | - user_roles.append( |
601 | | - {"userId": user.uid, "roleId": self.default_role.uid} |
602 | | - ) |
| 580 | + user_roles.append( |
| 581 | + {"userId": user.uid, "roleId": self.default_role.uid} |
| 582 | + ) |
603 | 583 |
|
604 | 584 | # Add members with their explicit roles |
605 | 585 | for member in self.members: |
606 | 586 | if member.user in eligible_users: |
607 | | - if ( |
608 | | - member.role.name.upper() |
609 | | - in self.UNASSIGNABLE_USERGROUP_ROLES |
610 | | - ): |
611 | | - invalid_roles.append( |
612 | | - f"Role '{member.role.name}' for user {member.user.uid} cannot be assigned in UserGroups" |
613 | | - ) |
614 | | - else: |
615 | | - user_roles.append( |
616 | | - {"userId": member.user.uid, "roleId": member.role.uid} |
617 | | - ) |
618 | | - |
619 | | - # Raise error if any invalid roles found |
620 | | - if invalid_roles: |
621 | | - raise ValueError( |
622 | | - f"Cannot create UserGroup with invalid roles.\n" |
623 | | - f"Unassignable roles: {', '.join(self.UNASSIGNABLE_USERGROUP_ROLES)}\n" |
624 | | - f"Issues found:\n" |
625 | | - + "\n".join(f" • {detail}" for detail in invalid_roles) |
626 | | - ) |
| 587 | + user_roles.append( |
| 588 | + {"userId": member.user.uid, "roleId": member.role.uid} |
| 589 | + ) |
627 | 590 |
|
628 | 591 | return user_roles |
629 | 592 |
|
|
0 commit comments