loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix network error when open/close organization/individual projects and redirect to project page (#30387)

Follow #27734

![image](https://github.com/go-gitea/gitea/assets/18380374/02ed6b9a-cbb6-4f49-a54a-ca76a0d052a9)

Updated:
Redirect to project page instead of project list page.

(cherry picked from commit af02b8a0e9b00a324fb92f1f73ea386dd9595c3d)

authored by

yp05327 and committed by
Gergely Nagy
9987b756 982e9ce5

+6 -11
+4 -4
routers/web/org/projects.go
··· 7 7 "errors" 8 8 "fmt" 9 9 "net/http" 10 - "net/url" 11 10 "strconv" 12 11 "strings" 13 12 ··· 195 194 196 195 // ChangeProjectStatus updates the status of a project between "open" and "close" 197 196 func ChangeProjectStatus(ctx *context.Context) { 198 - toClose := false 197 + var toClose bool 199 198 switch ctx.Params(":action") { 200 199 case "open": 201 200 toClose = false 202 201 case "close": 203 202 toClose = true 204 203 default: 205 - ctx.Redirect(ctx.ContextUser.HomeLink() + "/-/projects") 204 + ctx.JSONRedirect(ctx.ContextUser.HomeLink() + "/-/projects") 205 + return 206 206 } 207 207 id := ctx.ParamsInt64(":id") 208 208 ··· 210 210 ctx.NotFoundOrServerError("ChangeProjectStatusByRepoIDAndID", project_model.IsErrProjectNotExist, err) 211 211 return 212 212 } 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)) 214 214 } 215 215 216 216 // DeleteProject delete a project
+2 -7
routers/web/repo/projects.go
··· 7 7 "errors" 8 8 "fmt" 9 9 "net/http" 10 - "net/url" 11 10 "strings" 12 11 13 12 "code.gitea.io/gitea/models/db" ··· 180 179 id := ctx.ParamsInt64(":id") 181 180 182 181 if err := project_model.ChangeProjectStatusByRepoIDAndID(ctx, ctx.Repo.Repository.ID, id, toClose); err != nil { 183 - if project_model.IsErrProjectNotExist(err) { 184 - ctx.NotFound("", err) 185 - } else { 186 - ctx.ServerError("ChangeProjectStatusByIDAndRepoID", err) 187 - } 182 + ctx.NotFoundOrServerError("ChangeProjectStatusByRepoIDAndID", project_model.IsErrProjectNotExist, err) 188 183 return 189 184 } 190 - ctx.JSONRedirect(ctx.Repo.RepoLink + "/projects?state=" + url.QueryEscape(ctx.Params(":action"))) 185 + ctx.JSONRedirect(fmt.Sprintf("%s/projects/%d", ctx.Repo.RepoLink, id)) 191 186 } 192 187 193 188 // DeleteProject delete a project