diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2017-05-18 22:54:24 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-18 22:54:24 +0800 |
commit | fd6034aaf23af1ce03bcba0babcbe7675ce093ee (patch) | |
tree | 9720f416facdef02a76bd56ca50669cc1f17eb88 /models/org_team.go | |
parent | 5db5e16ab61f25f21cb17ee4895679b9830641a5 (diff) | |
download | gitea-fd6034aaf23af1ce03bcba0babcbe7675ce093ee.tar.gz gitea-fd6034aaf23af1ce03bcba0babcbe7675ce093ee.zip |
Add units to team (#947)
* add units to team
* fix lint
* finish team setting backend
* finished permission controll on routes
* fix import blank line
* add unit check on ssh/http pull and push and fix test failed
* fix fixtures data
* remove unused code
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 { |