mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-17 08:03:03 +02:00
add file with functions relating to organization teams and repo groups
This commit is contained in:
parent
423ef4c09c
commit
58126232fc
33
models/organization/team_group.go
Normal file
33
models/organization/team_group.go
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
package organization
|
||||||
|
|
||||||
|
import (
|
||||||
|
"code.gitea.io/gitea/models/db"
|
||||||
|
group_model "code.gitea.io/gitea/models/group"
|
||||||
|
"code.gitea.io/gitea/models/perm"
|
||||||
|
"code.gitea.io/gitea/models/unit"
|
||||||
|
"context"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetTeamsWithAccessToGroup(ctx context.Context, orgID, groupID int64, mode perm.AccessMode) ([]*Team, error) {
|
||||||
|
teams := make([]*Team, 0)
|
||||||
|
inCond := group_model.ParentGroupCond("group_team.group_id", groupID)
|
||||||
|
return teams, db.GetEngine(ctx).Where("group_team.access_mode >= ?", mode).
|
||||||
|
Join("INNER", "group_team", "group_team.team_id = team.id").
|
||||||
|
And("group_team.org_id = ?", orgID).
|
||||||
|
And(inCond).
|
||||||
|
OrderBy("name").
|
||||||
|
Find(&teams)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetTeamsWithAccessToGroupUnit(ctx context.Context, orgID, groupID int64, mode perm.AccessMode, unitType unit.Type) ([]*Team, error) {
|
||||||
|
teams := make([]*Team, 0)
|
||||||
|
inCond := group_model.ParentGroupCond("group_team.group_id", groupID)
|
||||||
|
return teams, db.GetEngine(ctx).Where("group_team.access_mode >= ?", mode).
|
||||||
|
Join("INNER", "group_team", "group_team.team_id = team.id").
|
||||||
|
Join("INNER", "group_unit", "group_unit.team_id = team.id").
|
||||||
|
And("group_team.org_id = ?", orgID).
|
||||||
|
And(inCond).
|
||||||
|
And("group_unit.type = ?", unitType).
|
||||||
|
OrderBy("name").
|
||||||
|
Find(&teams)
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user