Skip to content

Commit c272511

Browse files
dcramermattrobenolt
authored andcommitted
Merge pull request #2541 from getsentry/add-superusers-to-singular-teams
Default membership with singular teams
1 parent c9a1a54 commit c272511

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/sentry/runner/commands/createuser.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,27 @@ def createuser(email, password, superuser, no_password, no_input):
9090

9191
# TODO(dcramer): kill this when we improve flows
9292
if settings.SENTRY_SINGLE_ORGANIZATION:
93-
from sentry.models import Organization, OrganizationMember
93+
from sentry.models import (
94+
Organization, OrganizationMember, OrganizationMemberTeam, Team
95+
)
96+
9497
org = Organization.get_default()
9598
if superuser:
9699
role = roles.get_top_dog().id
97100
else:
98101
role = org.default_role
99-
OrganizationMember.objects.create(
102+
member = OrganizationMember.objects.create(
100103
organization=org,
101104
user=user,
102105
role=role,
103106
)
107+
108+
# if we've only got a single team let's go ahead and give
109+
# access to that team as its likely the desired outcome
110+
teams = list(Team.objects.filter(organization=org)[0:2])
111+
if len(teams) == 1:
112+
OrganizationMemberTeam.objects.create(
113+
team=teams[0],
114+
organizationmember=member,
115+
)
104116
click.echo('Added to organization: %s' % (org.slug,))

0 commit comments

Comments
 (0)