forked from kevadesu/forgejo
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:
parent
5db5e16ab6
commit
fd6034aaf2
18 changed files with 366 additions and 113 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue