0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-05-12 11:13:21 +02:00

add ParentGroup field and related LoadParentGroup method to Group struct

This commit is contained in:
☙◦ The Tablet ❀ GamerGirlandCo ◦❧ 2024-12-27 21:26:19 -05:00
parent ade1c082eb
commit 9fb94a8be1
No known key found for this signature in database
GPG Key ID: 924A5F6AF051E87C

View File

@ -22,6 +22,7 @@ type Group struct {
Avatar string `xorm:"VARCHAR(64)"`
ParentGroupID int64 `xorm:"INDEX DEFAULT NULL"`
ParentGroup *Group `xorm:"-"`
Subgroups GroupList `xorm:"-"`
}
@ -68,6 +69,18 @@ func (g *Group) LoadAttributes(ctx context.Context) error {
if err != nil {
return err
}
return g.LoadParentGroup(ctx)
}
func (g *Group) LoadParentGroup(ctx context.Context) error {
if g.ParentGroup != nil {
return nil
}
parentGroup, err := GetGroupByID(ctx, g.ParentGroupID)
if err != nil {
return err
}
g.ParentGroup = parentGroup
return nil
}