forked from kevadesu/forgejo
[refactor] replace int with httpStatusCodes (#15282)
* replace "200" (int) with "http.StatusOK" (const) * ctx.Error & ctx.HTML * ctx.JSON Part1 * ctx.JSON Part2 * ctx.JSON Part3
This commit is contained in:
parent
e9fba18a26
commit
16dea6cebd
64 changed files with 504 additions and 441 deletions
|
@ -7,6 +7,7 @@ package admin
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
|
@ -60,7 +61,7 @@ func NewUser(ctx *context.Context) {
|
|||
ctx.Data["Sources"] = sources
|
||||
|
||||
ctx.Data["CanSendEmail"] = setting.MailService != nil
|
||||
ctx.HTML(200, tplUserNew)
|
||||
ctx.HTML(http.StatusOK, tplUserNew)
|
||||
}
|
||||
|
||||
// NewUserPost response for adding a new user
|
||||
|
@ -80,7 +81,7 @@ func NewUserPost(ctx *context.Context) {
|
|||
ctx.Data["CanSendEmail"] = setting.MailService != nil
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, tplUserNew)
|
||||
ctx.HTML(http.StatusOK, tplUserNew)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -212,7 +213,7 @@ func EditUser(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
ctx.HTML(200, tplUserEdit)
|
||||
ctx.HTML(http.StatusOK, tplUserEdit)
|
||||
}
|
||||
|
||||
// EditUserPost response for editting user
|
||||
|
@ -229,7 +230,7 @@ func EditUserPost(ctx *context.Context) {
|
|||
}
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, tplUserEdit)
|
||||
ctx.HTML(http.StatusOK, tplUserEdit)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -348,12 +349,12 @@ func DeleteUser(ctx *context.Context) {
|
|||
switch {
|
||||
case models.IsErrUserOwnRepos(err):
|
||||
ctx.Flash.Error(ctx.Tr("admin.users.still_own_repo"))
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"redirect": setting.AppSubURL + "/admin/users/" + ctx.Params(":userid"),
|
||||
})
|
||||
case models.IsErrUserHasOrgs(err):
|
||||
ctx.Flash.Error(ctx.Tr("admin.users.still_has_org"))
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"redirect": setting.AppSubURL + "/admin/users/" + ctx.Params(":userid"),
|
||||
})
|
||||
default:
|
||||
|
@ -364,7 +365,7 @@ func DeleteUser(ctx *context.Context) {
|
|||
log.Trace("Account deleted by admin (%s): %s", ctx.User.Name, u.Name)
|
||||
|
||||
ctx.Flash.Success(ctx.Tr("admin.users.deletion_success"))
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"redirect": setting.AppSubURL + "/admin/users",
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue