diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-11-10 03:57:58 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-09 20:57:58 +0100 |
commit | 99b2858e628d92bba252be72def409af77af735b (patch) | |
tree | 56159cf10b271307911e6f01626c0c3efba789ab /models/org_team.go | |
parent | b6b1e716654fec3b16d245ef65cf42e57e1bb5b6 (diff) | |
download | gitea-99b2858e628d92bba252be72def409af77af735b.tar.gz gitea-99b2858e628d92bba252be72def409af77af735b.zip |
Move unit into models/unit/ (#17576)
* Move unit into models/unit/
* Rename unit.UnitType as unit.Type
Diffstat (limited to 'models/org_team.go')
-rw-r--r-- | models/org_team.go | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/models/org_team.go b/models/org_team.go index fc6a5f2c3b..10178ec88a 100644 --- a/models/org_team.go +++ b/models/org_team.go @@ -12,6 +12,7 @@ import ( "strings" "code.gitea.io/gitea/models/db" + "code.gitea.io/gitea/models/unit" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" @@ -135,7 +136,7 @@ func (t *Team) getUnits(e db.Engine) (err error) { // GetUnitNames returns the team units names func (t *Team) GetUnitNames() (res []string) { for _, u := range t.Units { - res = append(res, Units[u.Type].NameKey) + res = append(res, unit.Units[u.Type].NameKey) } return } @@ -435,11 +436,11 @@ func (t *Team) RemoveRepository(repoID int64) error { } // UnitEnabled returns if the team has the given unit type enabled -func (t *Team) UnitEnabled(tp UnitType) bool { +func (t *Team) UnitEnabled(tp unit.Type) bool { return t.unitEnabled(db.GetEngine(db.DefaultContext), tp) } -func (t *Team) unitEnabled(e db.Engine, tp UnitType) bool { +func (t *Team) unitEnabled(e db.Engine, tp unit.Type) bool { if err := t.getUnits(e); err != nil { log.Warn("Error loading team (ID: %d) units: %s", t.ID, err.Error()) } @@ -1029,15 +1030,15 @@ func GetTeamsWithAccessToRepo(orgID, repoID int64, mode AccessMode) ([]*Team, er // TeamUnit describes all units of a repository type TeamUnit struct { - ID int64 `xorm:"pk autoincr"` - OrgID int64 `xorm:"INDEX"` - TeamID int64 `xorm:"UNIQUE(s)"` - Type UnitType `xorm:"UNIQUE(s)"` + ID int64 `xorm:"pk autoincr"` + OrgID int64 `xorm:"INDEX"` + TeamID int64 `xorm:"UNIQUE(s)"` + Type unit.Type `xorm:"UNIQUE(s)"` } // Unit returns Unit -func (t *TeamUnit) Unit() Unit { - return Units[t.Type] +func (t *TeamUnit) Unit() unit.Unit { + return unit.Units[t.Type] } func getUnitsByTeamID(e db.Engine, teamID int64) (units []*TeamUnit, err error) { |