mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-10-10 19:32:02 +00:00
[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
|
@ -44,7 +44,7 @@ func Teams(ctx *context.Context) {
|
|||
}
|
||||
ctx.Data["Teams"] = org.Teams
|
||||
|
||||
ctx.HTML(200, tplTeams)
|
||||
ctx.HTML(http.StatusOK, tplTeams)
|
||||
}
|
||||
|
||||
// TeamsAction response for join, leave, remove, add operations to team
|
||||
|
@ -60,7 +60,7 @@ func TeamsAction(ctx *context.Context) {
|
|||
switch ctx.Params(":action") {
|
||||
case "join":
|
||||
if !ctx.Org.IsOwner {
|
||||
ctx.Error(404)
|
||||
ctx.Error(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
err = ctx.Org.Team.AddMember(ctx.User.ID)
|
||||
|
@ -68,14 +68,14 @@ func TeamsAction(ctx *context.Context) {
|
|||
err = ctx.Org.Team.RemoveMember(ctx.User.ID)
|
||||
case "remove":
|
||||
if !ctx.Org.IsOwner {
|
||||
ctx.Error(404)
|
||||
ctx.Error(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
err = ctx.Org.Team.RemoveMember(uid)
|
||||
page = "team"
|
||||
case "add":
|
||||
if !ctx.Org.IsOwner {
|
||||
ctx.Error(404)
|
||||
ctx.Error(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
uname := utils.RemoveUsernameParameterSuffix(strings.ToLower(ctx.Query("uname")))
|
||||
|
@ -111,7 +111,7 @@ func TeamsAction(ctx *context.Context) {
|
|||
ctx.Flash.Error(ctx.Tr("form.last_org_owner"))
|
||||
} else {
|
||||
log.Error("Action(%s): %v", ctx.Params(":action"), err)
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"ok": false,
|
||||
"err": err.Error(),
|
||||
})
|
||||
|
@ -132,7 +132,7 @@ func TeamsAction(ctx *context.Context) {
|
|||
// TeamsRepoAction operate team's repository
|
||||
func TeamsRepoAction(ctx *context.Context) {
|
||||
if !ctx.Org.IsOwner {
|
||||
ctx.Error(404)
|
||||
ctx.Error(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@ func TeamsRepoAction(ctx *context.Context) {
|
|||
}
|
||||
|
||||
if action == "addall" || action == "removeall" {
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"redirect": ctx.Org.OrgLink + "/teams/" + ctx.Org.Team.LowerName + "/repositories",
|
||||
})
|
||||
return
|
||||
|
@ -183,7 +183,7 @@ func NewTeam(ctx *context.Context) {
|
|||
ctx.Data["PageIsOrgTeamsNew"] = true
|
||||
ctx.Data["Team"] = &models.Team{}
|
||||
ctx.Data["Units"] = models.Units
|
||||
ctx.HTML(200, tplTeamNew)
|
||||
ctx.HTML(http.StatusOK, tplTeamNew)
|
||||
}
|
||||
|
||||
// NewTeamPost response for create new team
|
||||
|
@ -218,7 +218,7 @@ func NewTeamPost(ctx *context.Context) {
|
|||
ctx.Data["Team"] = t
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, tplTeamNew)
|
||||
ctx.HTML(http.StatusOK, tplTeamNew)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -250,7 +250,7 @@ func TeamMembers(ctx *context.Context) {
|
|||
ctx.ServerError("GetMembers", err)
|
||||
return
|
||||
}
|
||||
ctx.HTML(200, tplTeamMembers)
|
||||
ctx.HTML(http.StatusOK, tplTeamMembers)
|
||||
}
|
||||
|
||||
// TeamRepositories show the repositories of team
|
||||
|
@ -262,7 +262,7 @@ func TeamRepositories(ctx *context.Context) {
|
|||
ctx.ServerError("GetRepositories", err)
|
||||
return
|
||||
}
|
||||
ctx.HTML(200, tplTeamRepositories)
|
||||
ctx.HTML(http.StatusOK, tplTeamRepositories)
|
||||
}
|
||||
|
||||
// EditTeam render team edit page
|
||||
|
@ -272,7 +272,7 @@ func EditTeam(ctx *context.Context) {
|
|||
ctx.Data["team_name"] = ctx.Org.Team.Name
|
||||
ctx.Data["desc"] = ctx.Org.Team.Description
|
||||
ctx.Data["Units"] = models.Units
|
||||
ctx.HTML(200, tplTeamNew)
|
||||
ctx.HTML(http.StatusOK, tplTeamNew)
|
||||
}
|
||||
|
||||
// EditTeamPost response for modify team information
|
||||
|
@ -321,7 +321,7 @@ func EditTeamPost(ctx *context.Context) {
|
|||
t.CanCreateOrgRepo = form.CanCreateOrgRepo
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, tplTeamNew)
|
||||
ctx.HTML(http.StatusOK, tplTeamNew)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -351,7 +351,7 @@ func DeleteTeam(ctx *context.Context) {
|
|||
ctx.Flash.Success(ctx.Tr("org.teams.delete_team_success"))
|
||||
}
|
||||
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"redirect": ctx.Org.OrgLink + "/teams",
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue