|
|
@ -96,7 +96,7 @@ func (t *Team) addRepository(e Engine, repo *Repository) (err error) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
t.NumRepos++ |
|
|
|
t.NumRepos++ |
|
|
|
if _, err = e.Id(t.ID).Cols("num_repos").Update(t); err != nil { |
|
|
|
if _, err = e.ID(t.ID).Cols("num_repos").Update(t); err != nil { |
|
|
|
return fmt.Errorf("update team: %v", err) |
|
|
|
return fmt.Errorf("update team: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -142,7 +142,7 @@ func (t *Team) removeRepository(e Engine, repo *Repository, recalculate bool) (e |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
t.NumRepos-- |
|
|
|
t.NumRepos-- |
|
|
|
if _, err = e.Id(t.ID).Cols("num_repos").Update(t); err != nil { |
|
|
|
if _, err = e.ID(t.ID).Cols("num_repos").Update(t); err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -231,7 +231,7 @@ func NewTeam(t *Team) (err error) { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
has, err := x.Id(t.OrgID).Get(new(User)) |
|
|
|
has, err := x.ID(t.OrgID).Get(new(User)) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} else if !has { |
|
|
|
} else if !has { |
|
|
@ -289,7 +289,7 @@ func GetTeam(orgID int64, name string) (*Team, error) { |
|
|
|
|
|
|
|
|
|
|
|
func getTeamByID(e Engine, teamID int64) (*Team, error) { |
|
|
|
func getTeamByID(e Engine, teamID int64) (*Team, error) { |
|
|
|
t := new(Team) |
|
|
|
t := new(Team) |
|
|
|
has, err := e.Id(teamID).Get(t) |
|
|
|
has, err := e.ID(teamID).Get(t) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} else if !has { |
|
|
|
} else if !has { |
|
|
@ -331,7 +331,7 @@ func UpdateTeam(t *Team, authChanged bool) (err error) { |
|
|
|
return ErrTeamAlreadyExist{t.OrgID, t.LowerName} |
|
|
|
return ErrTeamAlreadyExist{t.OrgID, t.LowerName} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if _, err = sess.Id(t.ID).AllCols().Update(t); err != nil { |
|
|
|
if _, err = sess.ID(t.ID).AllCols().Update(t); err != nil { |
|
|
|
return fmt.Errorf("update: %v", err) |
|
|
|
return fmt.Errorf("update: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -387,7 +387,7 @@ func DeleteTeam(t *Team) error { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Delete team.
|
|
|
|
// Delete team.
|
|
|
|
if _, err := sess.Id(t.ID).Delete(new(Team)); err != nil { |
|
|
|
if _, err := sess.ID(t.ID).Delete(new(Team)); err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
// Update organization number of teams.
|
|
|
|
// Update organization number of teams.
|
|
|
@ -498,7 +498,7 @@ func AddTeamMember(team *Team, userID int64) error { |
|
|
|
TeamID: team.ID, |
|
|
|
TeamID: team.ID, |
|
|
|
}); err != nil { |
|
|
|
}); err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} else if _, err := sess.Id(team.ID).Update(team); err != nil { |
|
|
|
} else if _, err := sess.ID(team.ID).Update(team); err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -521,7 +521,7 @@ func AddTeamMember(team *Team, userID int64) error { |
|
|
|
if team.IsOwnerTeam() { |
|
|
|
if team.IsOwnerTeam() { |
|
|
|
ou.IsOwner = true |
|
|
|
ou.IsOwner = true |
|
|
|
} |
|
|
|
} |
|
|
|
if _, err := sess.Id(ou.ID).Cols("num_teams, is_owner").Update(ou); err != nil { |
|
|
|
if _, err := sess.ID(ou.ID).Cols("num_teams, is_owner").Update(ou); err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -551,7 +551,7 @@ func removeTeamMember(e Engine, team *Team, userID int64) error { |
|
|
|
}); err != nil { |
|
|
|
}); err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} else if _, err = e. |
|
|
|
} else if _, err = e. |
|
|
|
Id(team.ID). |
|
|
|
ID(team.ID). |
|
|
|
Cols("num_members"). |
|
|
|
Cols("num_members"). |
|
|
|
Update(team); err != nil { |
|
|
|
Update(team); err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
@ -578,7 +578,7 @@ func removeTeamMember(e Engine, team *Team, userID int64) error { |
|
|
|
ou.IsOwner = false |
|
|
|
ou.IsOwner = false |
|
|
|
} |
|
|
|
} |
|
|
|
if _, err = e. |
|
|
|
if _, err = e. |
|
|
|
Id(ou.ID). |
|
|
|
ID(ou.ID). |
|
|
|
Cols("num_teams"). |
|
|
|
Cols("num_teams"). |
|
|
|
Update(ou); err != nil { |
|
|
|
Update(ou); err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|