1
0
Fork 0
forked from forgejo/forgejo

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:
6543 2021-08-11 02:31:13 +02:00 committed by GitHub
parent 2eeae4edb6
commit c4d70a0325
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
64 changed files with 236 additions and 449 deletions

View file

@ -70,7 +70,7 @@ func SettingsPost(ctx *context.Context) {
repo := ctx.Repo.Repository
switch ctx.Form("action") {
switch ctx.FormString("action") {
case "update":
if ctx.HasError() {
ctx.HTML(http.StatusOK, tplSettingsOptions)
@ -560,7 +560,7 @@ func SettingsPost(ctx *context.Context) {
return
}
newOwner, err := models.GetUserByName(ctx.Form("new_owner_name"))
newOwner, err := models.GetUserByName(ctx.FormString("new_owner_name"))
if err != nil {
if models.IsErrUserNotExist(err) {
ctx.RenderWithErr(ctx.Tr("form.enterred_invalid_owner_name"), tplSettingsOptions, nil)
@ -775,7 +775,7 @@ func Collaboration(ctx *context.Context) {
// CollaborationPost response for actions for a collaboration of a repository
func CollaborationPost(ctx *context.Context) {
name := utils.RemoveUsernameParameterSuffix(strings.ToLower(ctx.Form("collaborator")))
name := utils.RemoveUsernameParameterSuffix(strings.ToLower(ctx.FormString("collaborator")))
if len(name) == 0 || ctx.Repo.Owner.LowerName == name {
ctx.Redirect(setting.AppSubURL + ctx.Req.URL.Path)
return
@ -854,7 +854,7 @@ func AddTeamPost(ctx *context.Context) {
return
}
name := utils.RemoveUsernameParameterSuffix(strings.ToLower(ctx.Form("team")))
name := utils.RemoveUsernameParameterSuffix(strings.ToLower(ctx.FormString("team")))
if len(name) == 0 {
ctx.Redirect(ctx.Repo.RepoLink + "/settings/collaboration")
return
@ -988,7 +988,7 @@ func GitHooksEditPost(ctx *context.Context) {
}
return
}
hook.Content = ctx.Form("content")
hook.Content = ctx.FormString("content")
if err = hook.Update(); err != nil {
ctx.ServerError("hook.Update", err)
return