@@ -32,9 +32,9 @@ type Group struct {
3232 Visibility structs.VisibleType `xorm:"NOT NULL DEFAULT 0"`
3333 Avatar string `xorm:"VARCHAR(64)"`
3434
35- ParentGroupID int64 `xorm:"DEFAULT NULL"`
36- ParentGroup * Group `xorm:"-"`
37- Subgroups GroupList `xorm:"-"`
35+ ParentGroupID int64 `xorm:"DEFAULT NULL"`
36+ ParentGroup * Group `xorm:"-"`
37+ Subgroups RepoGroupList `xorm:"-"`
3838
3939 SortOrder int `xorm:"INDEX"`
4040}
@@ -52,8 +52,8 @@ func (Group) TableName() string { return "repo_group" }
5252
5353func init () {
5454 db .RegisterModel (new (Group ))
55- db .RegisterModel (new (GroupTeam ))
56- db .RegisterModel (new (GroupUnit ))
55+ db .RegisterModel (new (RepoGroupTeam ))
56+ db .RegisterModel (new (RepoGroupUnit ))
5757}
5858
5959func (g * Group ) doLoadSubgroups (ctx context.Context , recursive bool , cond builder.Cond , currentLevel int ) error {
@@ -141,30 +141,30 @@ func (g *Group) CanAccessAtLevel(ctx context.Context, userID int64, level perm.A
141141func (g * Group ) IsOwnedBy (ctx context.Context , userID int64 ) (bool , error ) {
142142 return db .GetEngine (ctx ).
143143 Where ("team_user.uid = ?" , userID ).
144- Join ("INNER" , "team_user" , "team_user.team_id = group_team .team_id" ).
145- And ("group_team .access_mode = ?" , perm .AccessModeOwner ).
146- And ("group_team .group_id = ?" , g .ID ).
147- Table ("group_team " ).
144+ Join ("INNER" , "team_user" , "team_user.team_id = repo_group_team .team_id" ).
145+ And ("repo_group_team .access_mode = ?" , perm .AccessModeOwner ).
146+ And ("repo_group_team .group_id = ?" , g .ID ).
147+ Table ("repo_group_team " ).
148148 Exist ()
149149}
150150
151151func (g * Group ) CanCreateIn (ctx context.Context , userID int64 ) (bool , error ) {
152152 return db .GetEngine (ctx ).
153153 Where ("team_user.uid = ?" , userID ).
154- Join ("INNER" , "team_user" , "team_user.team_id = group_team .team_id" ).
155- And ("group_team .group_id = ?" , g .ID ).
156- And ("group_team .can_create_in = ?" , true ).
157- Table ("group_team " ).
154+ Join ("INNER" , "team_user" , "team_user.team_id = repo_group_team .team_id" ).
155+ And ("repo_group_team .group_id = ?" , g .ID ).
156+ And ("repo_group_team .can_create_in = ?" , true ).
157+ Table ("repo_group_team " ).
158158 Exist ()
159159}
160160
161161func (g * Group ) IsAdminOf (ctx context.Context , userID int64 ) (bool , error ) {
162162 return db .GetEngine (ctx ).
163163 Where ("team_user.uid = ?" , userID ).
164- Join ("INNER" , "team_user" , "team_user.team_id = group_team .team_id" ).
165- And ("group_team .group_id = ?" , g .ID ).
166- And ("group_team .access_mode >= ?" , perm .AccessModeAdmin ).
167- Table ("group_team " ).
164+ Join ("INNER" , "team_user" , "team_user.team_id = repo_group_team .team_id" ).
165+ And ("repo_group_team .group_id = ?" , g .ID ).
166+ And ("repo_group_team .access_mode >= ?" , perm .AccessModeAdmin ).
167+ Table ("repo_group_team " ).
168168 Exist ()
169169}
170170
@@ -224,19 +224,19 @@ func (opts FindGroupsOptions) ToConds() builder.Cond {
224224 }
225225 if opts .CanCreateIn .Has () && opts .ActorID > 0 {
226226 cond = cond .And (builder .In ("id" ,
227- builder .Select ("group_team .group_id" ).
228- From ("group_team " ).
227+ builder .Select ("repo_group_team .group_id" ).
228+ From ("repo_group_team " ).
229229 Where (builder.Eq {"team_user.uid" : opts .ActorID }).
230- Join ("INNER" , "team_user" , "team_user.team_id = group_team .team_id" ).
231- And (builder.Eq {"group_team .can_create_in" : true })))
230+ Join ("INNER" , "team_user" , "team_user.team_id = repo_group_team .team_id" ).
231+ And (builder.Eq {"repo_group_team .can_create_in" : true })))
232232 }
233233 if opts .Name != "" {
234234 cond = cond .And (builder.Eq {"lower_name" : opts .Name })
235235 }
236236 return cond
237237}
238238
239- func FindGroups (ctx context.Context , opts * FindGroupsOptions ) (GroupList , error ) {
239+ func FindGroups (ctx context.Context , opts * FindGroupsOptions ) (RepoGroupList , error ) {
240240 sess := db .GetEngine (ctx ).Where (opts .ToConds ())
241241 if opts .Page > 0 {
242242 sess = db .SetSessionPagination (sess , opts )
@@ -260,7 +260,7 @@ func findGroupsByCond(ctx context.Context, opts *FindGroupsOptions, cond builder
260260 return sess .Asc ("sort_order" )
261261}
262262
263- func FindGroupsByCond (ctx context.Context , opts * FindGroupsOptions , cond builder.Cond ) (GroupList , error ) {
263+ func FindGroupsByCond (ctx context.Context , opts * FindGroupsOptions , cond builder.Cond ) (RepoGroupList , error ) {
264264 defaultSize := 50
265265 if opts .PageSize > 0 {
266266 defaultSize = opts .PageSize
@@ -285,7 +285,7 @@ func UpdateGroupOwnerName(ctx context.Context, oldUser, newUser string) error {
285285}
286286
287287// GetParentGroupChain returns a slice containing a group and its ancestors
288- func GetParentGroupChain (ctx context.Context , groupID int64 ) (GroupList , error ) {
288+ func GetParentGroupChain (ctx context.Context , groupID int64 ) (RepoGroupList , error ) {
289289 groupList := make ([]* Group , 0 , 20 )
290290 currentGroupID := groupID
291291 for {
@@ -306,15 +306,16 @@ func GetParentGroupChain(ctx context.Context, groupID int64) (GroupList, error)
306306 return groupList , nil
307307}
308308
309- func GetParentGroupIDChain (ctx context.Context , groupID int64 ) (ids []int64 , err error ) {
309+ func GetParentGroupIDChain (ctx context.Context , groupID int64 ) ([]int64 , error ) {
310+ var ids []int64
310311 groupList , err := GetParentGroupChain (ctx , groupID )
311312 if err != nil {
312313 return nil , err
313314 }
314315 ids = util .SliceMap (groupList , func (g * Group ) int64 {
315316 return g .ID
316317 })
317- return
318+ return ids , err
318319}
319320
320321// ParentGroupCond returns a condition matching a group and its ancestors
0 commit comments