Add a description field to teams.
This commit is contained in:
parent
7991c3eff8
commit
ac71822352
4 changed files with 7 additions and 4 deletions
|
@ -45,6 +45,7 @@ class Team(BaseModel):
|
|||
name = CharField(index=True)
|
||||
organization = ForeignKeyField(User, index=True)
|
||||
role = ForeignKeyField(TeamRole)
|
||||
description = TextField(default='')
|
||||
|
||||
class Meta:
|
||||
database = db
|
||||
|
|
|
@ -89,7 +89,7 @@ def create_organization(name, email, creating_user):
|
|||
new_org.save()
|
||||
|
||||
# Create a team for the owners
|
||||
owners_team = create_team('Owners', new_org, 'admin')
|
||||
owners_team = create_team('owners', new_org, 'admin')
|
||||
|
||||
# Add the user who created the org to the owners team
|
||||
add_user_to_team(creating_user, owners_team)
|
||||
|
@ -99,7 +99,7 @@ def create_organization(name, email, creating_user):
|
|||
raise InvalidOrganizationException('Invalid organization name: %s' % name)
|
||||
|
||||
|
||||
def create_team(name, org, team_role_name):
|
||||
def create_team(name, org, team_role_name, description=''):
|
||||
if not validate_username(name):
|
||||
raise InvalidTeamException('Invalid team name: %s' % name)
|
||||
|
||||
|
@ -108,7 +108,8 @@ def create_team(name, org, team_role_name):
|
|||
org.username)
|
||||
|
||||
team_role = TeamRole.get(TeamRole.name == team_role_name)
|
||||
return Team.create(name=name, organization=org, role=team_role)
|
||||
return Team.create(name=name, organization=org, role=team_role,
|
||||
description=description)
|
||||
|
||||
|
||||
def add_user_to_team(user, team):
|
||||
|
|
|
@ -156,7 +156,8 @@ if __name__ == '__main__':
|
|||
'Repository owned by an org.', False,
|
||||
[], (4, [], ['latest', 'prod']))
|
||||
|
||||
reader_team = model.create_team('Readers', org, 'member')
|
||||
reader_team = model.create_team('readers', org, 'member',
|
||||
'Readers of orgrepo.')
|
||||
model.set_team_repo_permission(reader_team.name, org_repo.namespace,
|
||||
org_repo.name, 'read')
|
||||
model.add_user_to_team(new_user_2, reader_team)
|
||||
|
|
Binary file not shown.
Reference in a new issue