Skip to content

Commit 30a593d

Browse files
authored
Fix network error when open/close organization/individual projects and redirect to project page (#30387) (#30911)
Backport #30387 Fix #30901
1 parent 6c235f4 commit 30a593d

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

routers/web/org/projects.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"errors"
88
"fmt"
99
"net/http"
10-
"net/url"
1110
"strconv"
1211
"strings"
1312

@@ -191,14 +190,15 @@ func NewProjectPost(ctx *context.Context) {
191190

192191
// ChangeProjectStatus updates the status of a project between "open" and "close"
193192
func ChangeProjectStatus(ctx *context.Context) {
194-
toClose := false
193+
var toClose bool
195194
switch ctx.Params(":action") {
196195
case "open":
197196
toClose = false
198197
case "close":
199198
toClose = true
200199
default:
201-
ctx.Redirect(ctx.ContextUser.HomeLink() + "/-/projects")
200+
ctx.JSONRedirect(ctx.ContextUser.HomeLink() + "/-/projects")
201+
return
202202
}
203203
id := ctx.ParamsInt64(":id")
204204

@@ -210,7 +210,7 @@ func ChangeProjectStatus(ctx *context.Context) {
210210
}
211211
return
212212
}
213-
ctx.Redirect(ctx.ContextUser.HomeLink() + "/-/projects?state=" + url.QueryEscape(ctx.Params(":action")))
213+
ctx.JSONRedirect(fmt.Sprintf("%s/-/projects/%d", ctx.ContextUser.HomeLink(), id))
214214
}
215215

216216
// DeleteProject delete a project

routers/web/repo/projects.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"errors"
88
"fmt"
99
"net/http"
10-
"net/url"
1110
"strings"
1211

1312
issues_model "code.gitea.io/gitea/models/issues"
@@ -176,14 +175,10 @@ func ChangeProjectStatus(ctx *context.Context) {
176175
id := ctx.ParamsInt64(":id")
177176

178177
if err := project_model.ChangeProjectStatusByRepoIDAndID(ctx, ctx.Repo.Repository.ID, id, toClose); err != nil {
179-
if project_model.IsErrProjectNotExist(err) {
180-
ctx.NotFound("", err)
181-
} else {
182-
ctx.ServerError("ChangeProjectStatusByIDAndRepoID", err)
183-
}
178+
ctx.NotFoundOrServerError("ChangeProjectStatusByRepoIDAndID", project_model.IsErrProjectNotExist, err)
184179
return
185180
}
186-
ctx.JSONRedirect(ctx.Repo.RepoLink + "/projects?state=" + url.QueryEscape(ctx.Params(":action")))
181+
ctx.JSONRedirect(fmt.Sprintf("%s/projects/%d", ctx.Repo.RepoLink, id))
187182
}
188183

189184
// DeleteProject delete a project

0 commit comments

Comments
 (0)