Skip to content

Commit 02300ca

Browse files
update group team routes
- ensure we redirect to the group's team page, as opposed to the org-wide one - ensure we use the group service to add a team to a group
1 parent 75c8e02 commit 02300ca

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

routers/web/group/team.go

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package group
55

66
import (
7+
"fmt"
78
"net/http"
89
"strings"
910

@@ -147,7 +148,7 @@ func EditTeamPost(ctx *context.Context) {
147148
ctx.ServerError("UpdateGroupTeam", err)
148149
return
149150
}
150-
ctx.Redirect(ctx.Org.OrgLink + "/teams/")
151+
ctx.Redirect(ctx.Org.OrgLink + fmt.Sprintf("/groups/%d/teams", gt.GroupID))
151152
}
152153

153154
func TeamAddPost(ctx *context.Context) {
@@ -171,22 +172,11 @@ func TeamAddPost(ctx *context.Context) {
171172
if has {
172173
ctx.Flash.Error(ctx.Tr("org.group.add_duplicate_team"))
173174
} else {
174-
parentGroup, err := group_model.FindGroupTeamByTeamID(ctx, group.ID, t.ID)
175-
if err != nil {
176-
ctx.ServerError("FindGroupTeamByTeamID", err)
177-
return
178-
}
179-
mode := t.AccessMode
180-
canCreateIn := t.CanCreateOrgRepo
181-
if parentGroup != nil {
182-
mode = max(t.AccessMode, parentGroup.AccessMode)
183-
canCreateIn = parentGroup.CanCreateIn || t.CanCreateOrgRepo
184-
}
185175
if err = group.LoadParentGroup(ctx); err != nil {
186176
ctx.ServerError("LoadParentGroup", err)
187177
return
188178
}
189-
err = group_model.AddTeamGroup(ctx, ctx.RepoGroup.Group.OwnerID, t.ID, ctx.RepoGroup.Group.ID, mode, canCreateIn)
179+
err = group_service.AddTeamToGroup(ctx, group, tname)
190180
if err != nil {
191181
ctx.ServerError("AddTeamGroup", err)
192182
return

0 commit comments

Comments
 (0)