mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-31 20:02:09 +00:00
Move web JSON functions to web context and simplify code (#26132)
The JSONRedirect/JSONOK/JSONError functions were put into "Base" context incorrectly, it would cause abuse. Actually, they are for "web context" only, so, move them to the correct place. And by the way, use them to simplify old code: +75 -196
This commit is contained in:
parent
338d03ce2f
commit
dcd3a63128
36 changed files with 75 additions and 196 deletions
|
@ -219,9 +219,7 @@ func DeleteProject(ctx *context.Context) {
|
|||
ctx.Flash.Success(ctx.Tr("repo.projects.deletion_success"))
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, map[string]any{
|
||||
"redirect": ctx.ContextUser.HomeLink() + "/-/projects",
|
||||
})
|
||||
ctx.JSONRedirect(ctx.ContextUser.HomeLink() + "/-/projects")
|
||||
}
|
||||
|
||||
// RenderEditProject allows a project to be edited
|
||||
|
@ -449,9 +447,7 @@ func UpdateIssueProject(ctx *context.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, map[string]any{
|
||||
"ok": true,
|
||||
})
|
||||
ctx.JSONOK()
|
||||
}
|
||||
|
||||
// DeleteProjectBoard allows for the deletion of a project board
|
||||
|
@ -497,9 +493,7 @@ func DeleteProjectBoard(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, map[string]any{
|
||||
"ok": true,
|
||||
})
|
||||
ctx.JSONOK()
|
||||
}
|
||||
|
||||
// AddBoardToProjectPost allows a new board to be added to a project.
|
||||
|
@ -526,9 +520,7 @@ func AddBoardToProjectPost(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, map[string]any{
|
||||
"ok": true,
|
||||
})
|
||||
ctx.JSONOK()
|
||||
}
|
||||
|
||||
// CheckProjectBoardChangePermissions check permission
|
||||
|
@ -594,9 +586,7 @@ func EditProjectBoard(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, map[string]any{
|
||||
"ok": true,
|
||||
})
|
||||
ctx.JSONOK()
|
||||
}
|
||||
|
||||
// SetDefaultProjectBoard set default board for uncategorized issues/pulls
|
||||
|
@ -611,9 +601,7 @@ func SetDefaultProjectBoard(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, map[string]any{
|
||||
"ok": true,
|
||||
})
|
||||
ctx.JSONOK()
|
||||
}
|
||||
|
||||
// UnsetDefaultProjectBoard unset default board for uncategorized issues/pulls
|
||||
|
@ -628,9 +616,7 @@ func UnsetDefaultProjectBoard(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, map[string]any{
|
||||
"ok": true,
|
||||
})
|
||||
ctx.JSONOK()
|
||||
}
|
||||
|
||||
// MoveIssues moves or keeps issues in a column and sorts them inside that column
|
||||
|
@ -730,7 +716,5 @@ func MoveIssues(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, map[string]any{
|
||||
"ok": true,
|
||||
})
|
||||
ctx.JSONOK()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue