mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-09 22:51:50 +02:00
add function to find teams a user is part of within a group
This commit is contained in:
parent
09f0464384
commit
83d982cc38
@ -59,7 +59,7 @@ func HasTeamGroup(ctx context.Context, orgID, teamID, groupID int64) bool {
|
||||
|
||||
// AddTeamGroup adds a group to a team
|
||||
func AddTeamGroup(ctx context.Context, orgID, teamID, groupID int64, access perm.AccessMode, canCreateIn bool) error {
|
||||
if access <= perm.AccessModeWrite {
|
||||
if access < perm.AccessModeWrite {
|
||||
canCreateIn = false
|
||||
}
|
||||
_, err := db.GetEngine(ctx).Insert(&RepoGroupTeam{
|
||||
@ -113,6 +113,15 @@ func FindGroupTeams(ctx context.Context, groupID int64) (gteams []*RepoGroupTeam
|
||||
Find(>eams)
|
||||
}
|
||||
|
||||
func FindUserGroupTeams(ctx context.Context, groupID int64, userID int64) (gteams []*RepoGroupTeam, err error) {
|
||||
return gteams, db.GetEngine(ctx).
|
||||
Where("group_id=?", groupID).
|
||||
And("team_user.uid = ?", userID).
|
||||
Table("repo_group_team").
|
||||
Join("INNER", "team_user", "team_user.team_id = repo_group_team.team_id").
|
||||
Find(>eams)
|
||||
}
|
||||
|
||||
func FindGroupTeamByTeamID(ctx context.Context, groupID, teamID int64) (gteam *RepoGroupTeam, err error) {
|
||||
gteam = new(RepoGroupTeam)
|
||||
has, err := db.GetEngine(ctx).
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user