Redesign the teams page to use a table
Allows for faster loading and easier viewing of important information about teams
This commit is contained in:
parent
98206310bd
commit
6ebb417923
11 changed files with 194 additions and 168 deletions
|
@ -1,7 +1,9 @@
|
|||
from data.database import Team, TeamMember, TeamRole, User, TeamMemberInvite
|
||||
from data.database import Team, TeamMember, TeamRole, User, TeamMemberInvite, RepositoryPermission
|
||||
from data.model import (DataModelException, InvalidTeamException, UserAlreadyInTeam,
|
||||
InvalidTeamMemberException, user, _basequery)
|
||||
from util.validation import validate_username
|
||||
from peewee import fn, JOIN_LEFT_OUTER
|
||||
from util.morecollections import AttrDict
|
||||
|
||||
|
||||
def create_team(name, org_obj, team_role_name, description=''):
|
||||
|
@ -186,7 +188,32 @@ def get_matching_teams(team_prefix, organization):
|
|||
|
||||
|
||||
def get_teams_within_org(organization):
|
||||
return Team.select().where(Team.organization == organization)
|
||||
""" Returns a AttrDict of team info (id, name, description), its role under the org,
|
||||
the number of repositories on which it has permission, and the number of members.
|
||||
"""
|
||||
query = (Team.select(Team.id, Team.name, Team.description, TeamRole.name,
|
||||
fn.Count(RepositoryPermission.id), fn.Count(TeamMember.id))
|
||||
.where(Team.organization == organization)
|
||||
.join(TeamRole)
|
||||
.switch(Team)
|
||||
.join(RepositoryPermission, JOIN_LEFT_OUTER)
|
||||
.switch(Team)
|
||||
.join(TeamMember, JOIN_LEFT_OUTER)
|
||||
.group_by(Team.id)
|
||||
.tuples())
|
||||
|
||||
def _team_view(team_tuple):
|
||||
return AttrDict({
|
||||
'id': team_tuple[0],
|
||||
'name': team_tuple[1],
|
||||
'description': team_tuple[2],
|
||||
'role_name': team_tuple[3],
|
||||
|
||||
'repo_count': team_tuple[4],
|
||||
'member_count': team_tuple[5],
|
||||
})
|
||||
|
||||
return [_team_view(team_tuple) for team_tuple in query]
|
||||
|
||||
|
||||
def get_user_teams_within_org(username, organization):
|
||||
|
|
Reference in a new issue