mirror of
https://github.com/go-gitea/gitea
synced 2025-07-23 18:58:38 +00:00
Rename ctx.Form() to ctx.FormString() and move code into own file (#16571)
Followup from #16562 prepare for #16567 * Rename ctx.Form() to ctx.FormString() * Reimplement FormX func to need less code and cpu cycles * Move code into own file
This commit is contained in:
@@ -51,8 +51,8 @@ func Home(ctx *context.Context) {
|
||||
}
|
||||
|
||||
var orderBy models.SearchOrderBy
|
||||
ctx.Data["SortType"] = ctx.Form("sort")
|
||||
switch ctx.Form("sort") {
|
||||
ctx.Data["SortType"] = ctx.FormString("sort")
|
||||
switch ctx.FormString("sort") {
|
||||
case "newest":
|
||||
orderBy = models.SearchOrderByNewest
|
||||
case "oldest":
|
||||
@@ -78,7 +78,7 @@ func Home(ctx *context.Context) {
|
||||
orderBy = models.SearchOrderByRecentUpdated
|
||||
}
|
||||
|
||||
keyword := strings.Trim(ctx.Form("q"), " ")
|
||||
keyword := strings.Trim(ctx.FormString("q"), " ")
|
||||
ctx.Data["Keyword"] = keyword
|
||||
|
||||
page := ctx.FormInt("page")
|
||||
|
@@ -15,7 +15,7 @@ import (
|
||||
|
||||
// RetrieveLabels find all the labels of an organization
|
||||
func RetrieveLabels(ctx *context.Context) {
|
||||
labels, err := models.GetLabelsByOrgID(ctx.Org.Organization.ID, ctx.Form("sort"), models.ListOptions{})
|
||||
labels, err := models.GetLabelsByOrgID(ctx.Org.Organization.ID, ctx.FormString("sort"), models.ListOptions{})
|
||||
if err != nil {
|
||||
ctx.ServerError("RetrieveLabels.GetLabels", err)
|
||||
return
|
||||
@@ -25,7 +25,7 @@ func RetrieveLabels(ctx *context.Context) {
|
||||
}
|
||||
ctx.Data["Labels"] = labels
|
||||
ctx.Data["NumLabels"] = len(labels)
|
||||
ctx.Data["SortType"] = ctx.Form("sort")
|
||||
ctx.Data["SortType"] = ctx.FormString("sort")
|
||||
}
|
||||
|
||||
// NewLabel create new label for organization
|
||||
|
@@ -155,7 +155,7 @@ func SettingsDelete(ctx *context.Context) {
|
||||
|
||||
org := ctx.Org.Organization
|
||||
if ctx.Req.Method == "POST" {
|
||||
if org.Name != ctx.Form("org_name") {
|
||||
if org.Name != ctx.FormString("org_name") {
|
||||
ctx.Data["Err_OrgName"] = true
|
||||
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_org_name"), tplSettingsDelete, nil)
|
||||
return
|
||||
|
@@ -55,7 +55,7 @@ func TeamsAction(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
page := ctx.Form("page")
|
||||
page := ctx.FormString("page")
|
||||
var err error
|
||||
switch ctx.Params(":action") {
|
||||
case "join":
|
||||
@@ -78,7 +78,7 @@ func TeamsAction(ctx *context.Context) {
|
||||
ctx.Error(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
uname := utils.RemoveUsernameParameterSuffix(strings.ToLower(ctx.Form("uname")))
|
||||
uname := utils.RemoveUsernameParameterSuffix(strings.ToLower(ctx.FormString("uname")))
|
||||
var u *models.User
|
||||
u, err = models.GetUserByName(uname)
|
||||
if err != nil {
|
||||
@@ -140,7 +140,7 @@ func TeamsRepoAction(ctx *context.Context) {
|
||||
action := ctx.Params(":action")
|
||||
switch action {
|
||||
case "add":
|
||||
repoName := path.Base(ctx.Form("repo_name"))
|
||||
repoName := path.Base(ctx.FormString("repo_name"))
|
||||
var repo *models.Repository
|
||||
repo, err = models.GetRepositoryByName(ctx.Org.Organization.ID, repoName)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user