diff options
Diffstat (limited to 'models/org_team.go')
-rw-r--r-- | models/org_team.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/models/org_team.go b/models/org_team.go index 115e13feab..5c97a7032e 100644 --- a/models/org_team.go +++ b/models/org_team.go @@ -24,6 +24,15 @@ type Team struct { Members []*User `xorm:"-"` NumRepos int NumMembers int + UnitTypes []UnitType `xorm:"json"` +} + +// GetUnitTypes returns unit types the team owned, empty means all the unit types +func (t *Team) GetUnitTypes() []UnitType { + if len(t.UnitTypes) == 0 { + return allRepUnitTypes + } + return t.UnitTypes } // IsOwnerTeam returns true if team is owner team. @@ -183,6 +192,19 @@ func (t *Team) RemoveRepository(repoID int64) error { return sess.Commit() } +// EnableUnit returns if the team enables unit type t +func (t *Team) EnableUnit(tp UnitType) bool { + if len(t.UnitTypes) == 0 { + return true + } + for _, u := range t.UnitTypes { + if u == tp { + return true + } + } + return false +} + // IsUsableTeamName tests if a name could be as team name func IsUsableTeamName(name string) error { switch name { |