mirror of
https://github.com/go-gitea/gitea.git
synced 2025-06-21 21:48:00 +02:00
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
This commit is contained in:
@ -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 {
|
||||
|
Reference in New Issue
Block a user