Start on organization conversion. Note that this does not yet move over the user's plan to an org plan

This commit is contained in:
Joseph Schorr 2013-11-07 16:33:56 -05:00
parent a7415ef4d3
commit 3f2d51651e
5 changed files with 241 additions and 1 deletions

View file

@ -99,6 +99,22 @@ def create_organization(name, email, creating_user):
raise InvalidOrganizationException('Invalid organization name: %s' % name)
def convert_user_to_organization(user, admin_user):
# Change the user to an organization.
user.organization = True
# TODO: disable this account for login.
user.password = ''
user.save()
# Create a team for the owners
owners_team = create_team('owners', user, 'admin')
# Add the user who will admin the org to the owners team
add_user_to_team(admin_user, owners_team)
return user
def create_team(name, org, team_role_name, description=''):
if not validate_username(name):
raise InvalidTeamException('Invalid team name: %s' % name)