0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-05-14 00:01:05 +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 807028a194
commit 4328885e9b
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
}