File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed
django/thunderstore/api/cyberstorm/services Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change 1+ from django .core .exceptions import ValidationError
12from django .db import transaction
23
34from thunderstore .account .models import ServiceAccount
45from thunderstore .core .exceptions import PermissionValidationError
56from thunderstore .core .types import UserType
67from thunderstore .repository .models import Team , TeamMember
8+ from thunderstore .repository .models .namespace import Namespace
79from thunderstore .repository .models .team import TeamMemberRole
810
911
@@ -20,6 +22,10 @@ def create_team(agent: UserType, team_name: str) -> Team:
2022 raise PermissionValidationError ("Must be authenticated to create teams" )
2123 if getattr (agent , "service_account" , None ) is not None :
2224 raise PermissionValidationError ("Service accounts cannot create teams" )
25+ if Team .objects .filter (name__iexact = team_name ).exists ():
26+ raise ValidationError ("Team with this name already exists" )
27+ if Namespace .objects .filter (name__iexact = team_name ).exists ():
28+ raise ValidationError ("Namespace with this name already exists" )
2329
2430 team = Team .create (name = team_name )
2531 team .add_member (user = agent , role = TeamMemberRole .owner )
You can’t perform that action at this time.
0 commit comments