mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Rename context.Query to context.Form (#16562)
This commit is contained in:
@@ -161,7 +161,7 @@ func DashboardPost(ctx *context.Context) {
|
||||
|
||||
// SendTestMail send test mail to confirm mail service is OK
|
||||
func SendTestMail(ctx *context.Context) {
|
||||
email := ctx.Query("email")
|
||||
email := ctx.Form("email")
|
||||
// Send a test email to the user's email address and redirect back to Config
|
||||
if err := mailer.SendTestMail(email); err != nil {
|
||||
ctx.Flash.Error(ctx.Tr("admin.config.test_mail_failed", email, err))
|
||||
@@ -377,7 +377,7 @@ func Flush(ctx *context.Context) {
|
||||
ctx.Status(404)
|
||||
return
|
||||
}
|
||||
timeout, err := time.ParseDuration(ctx.Query("timeout"))
|
||||
timeout, err := time.ParseDuration(ctx.Form("timeout"))
|
||||
if err != nil {
|
||||
timeout = -1
|
||||
}
|
||||
@@ -399,13 +399,13 @@ func AddWorkers(ctx *context.Context) {
|
||||
ctx.Status(404)
|
||||
return
|
||||
}
|
||||
number := ctx.QueryInt("number")
|
||||
number := ctx.FormInt("number")
|
||||
if number < 1 {
|
||||
ctx.Flash.Error(ctx.Tr("admin.monitor.queue.pool.addworkers.mustnumbergreaterzero"))
|
||||
ctx.Redirect(setting.AppSubURL + "/admin/monitor/queue/" + strconv.FormatInt(qid, 10))
|
||||
return
|
||||
}
|
||||
timeout, err := time.ParseDuration(ctx.Query("timeout"))
|
||||
timeout, err := time.ParseDuration(ctx.Form("timeout"))
|
||||
if err != nil {
|
||||
ctx.Flash.Error(ctx.Tr("admin.monitor.queue.pool.addworkers.musttimeoutduration"))
|
||||
ctx.Redirect(setting.AppSubURL + "/admin/monitor/queue/" + strconv.FormatInt(qid, 10))
|
||||
@@ -435,9 +435,9 @@ func SetQueueSettings(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
maxNumberStr := ctx.Query("max-number")
|
||||
numberStr := ctx.Query("number")
|
||||
timeoutStr := ctx.Query("timeout")
|
||||
maxNumberStr := ctx.Form("max-number")
|
||||
numberStr := ctx.Form("number")
|
||||
timeoutStr := ctx.Form("timeout")
|
||||
|
||||
var err error
|
||||
var maxNumber, number int
|
||||
|
@@ -30,7 +30,7 @@ func Emails(ctx *context.Context) {
|
||||
opts := &models.SearchEmailOptions{
|
||||
ListOptions: models.ListOptions{
|
||||
PageSize: setting.UI.Admin.UserPagingNum,
|
||||
Page: ctx.QueryInt("page"),
|
||||
Page: ctx.FormInt("page"),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -51,8 +51,8 @@ func Emails(ctx *context.Context) {
|
||||
orderBy models.SearchEmailOrderBy
|
||||
)
|
||||
|
||||
ctx.Data["SortType"] = ctx.Query("sort")
|
||||
switch ctx.Query("sort") {
|
||||
ctx.Data["SortType"] = ctx.Form("sort")
|
||||
switch ctx.Form("sort") {
|
||||
case "email":
|
||||
orderBy = models.SearchEmailOrderByEmail
|
||||
case "reverseemail":
|
||||
@@ -66,13 +66,13 @@ func Emails(ctx *context.Context) {
|
||||
orderBy = models.SearchEmailOrderByEmail
|
||||
}
|
||||
|
||||
opts.Keyword = ctx.QueryTrim("q")
|
||||
opts.Keyword = ctx.FormTrim("q")
|
||||
opts.SortType = orderBy
|
||||
if len(ctx.Query("is_activated")) != 0 {
|
||||
opts.IsActivated = util.OptionalBoolOf(ctx.QueryBool("activated"))
|
||||
if len(ctx.Form("is_activated")) != 0 {
|
||||
opts.IsActivated = util.OptionalBoolOf(ctx.FormBool("activated"))
|
||||
}
|
||||
if len(ctx.Query("is_primary")) != 0 {
|
||||
opts.IsPrimary = util.OptionalBoolOf(ctx.QueryBool("primary"))
|
||||
if len(ctx.Form("is_primary")) != 0 {
|
||||
opts.IsPrimary = util.OptionalBoolOf(ctx.FormBool("primary"))
|
||||
}
|
||||
|
||||
if len(opts.Keyword) == 0 || isKeywordValid(opts.Keyword) {
|
||||
@@ -113,10 +113,10 @@ func ActivateEmail(ctx *context.Context) {
|
||||
|
||||
truefalse := map[string]bool{"1": true, "0": false}
|
||||
|
||||
uid := ctx.QueryInt64("uid")
|
||||
email := ctx.Query("email")
|
||||
primary, okp := truefalse[ctx.Query("primary")]
|
||||
activate, oka := truefalse[ctx.Query("activate")]
|
||||
uid := ctx.FormInt64("uid")
|
||||
email := ctx.Form("email")
|
||||
primary, okp := truefalse[ctx.Form("primary")]
|
||||
activate, oka := truefalse[ctx.Form("activate")]
|
||||
|
||||
if uid == 0 || len(email) == 0 || !okp || !oka {
|
||||
ctx.Error(http.StatusBadRequest)
|
||||
@@ -139,16 +139,16 @@ func ActivateEmail(ctx *context.Context) {
|
||||
|
||||
redirect, _ := url.Parse(setting.AppSubURL + "/admin/emails")
|
||||
q := url.Values{}
|
||||
if val := ctx.QueryTrim("q"); len(val) > 0 {
|
||||
if val := ctx.FormTrim("q"); len(val) > 0 {
|
||||
q.Set("q", val)
|
||||
}
|
||||
if val := ctx.QueryTrim("sort"); len(val) > 0 {
|
||||
if val := ctx.FormTrim("sort"); len(val) > 0 {
|
||||
q.Set("sort", val)
|
||||
}
|
||||
if val := ctx.QueryTrim("is_primary"); len(val) > 0 {
|
||||
if val := ctx.FormTrim("is_primary"); len(val) > 0 {
|
||||
q.Set("is_primary", val)
|
||||
}
|
||||
if val := ctx.QueryTrim("is_activated"); len(val) > 0 {
|
||||
if val := ctx.FormTrim("is_activated"); len(val) > 0 {
|
||||
q.Set("is_activated", val)
|
||||
}
|
||||
redirect.RawQuery = q.Encode()
|
||||
|
@@ -60,7 +60,7 @@ func DefaultOrSystemWebhooks(ctx *context.Context) {
|
||||
|
||||
// DeleteDefaultOrSystemWebhook handler to delete an admin-defined system or default webhook
|
||||
func DeleteDefaultOrSystemWebhook(ctx *context.Context) {
|
||||
if err := models.DeleteDefaultSystemWebhook(ctx.QueryInt64("id")); err != nil {
|
||||
if err := models.DeleteDefaultSystemWebhook(ctx.FormInt64("id")); err != nil {
|
||||
ctx.Flash.Error("DeleteDefaultWebhook: " + err.Error())
|
||||
} else {
|
||||
ctx.Flash.Success(ctx.Tr("repo.settings.webhook_deletion_success"))
|
||||
|
@@ -27,7 +27,7 @@ func Notices(ctx *context.Context) {
|
||||
ctx.Data["PageIsAdminNotices"] = true
|
||||
|
||||
total := models.CountNotices()
|
||||
page := ctx.QueryInt("page")
|
||||
page := ctx.FormInt("page")
|
||||
if page <= 1 {
|
||||
page = 1
|
||||
}
|
||||
@@ -48,7 +48,7 @@ func Notices(ctx *context.Context) {
|
||||
|
||||
// DeleteNotices delete the specific notices
|
||||
func DeleteNotices(ctx *context.Context) {
|
||||
strs := ctx.QueryStrings("ids[]")
|
||||
strs := ctx.FormStrings("ids[]")
|
||||
ids := make([]int64, 0, len(strs))
|
||||
for i := range strs {
|
||||
id, _ := strconv.ParseInt(strs[i], 10, 64)
|
||||
|
@@ -41,7 +41,7 @@ func Repos(ctx *context.Context) {
|
||||
|
||||
// DeleteRepo delete one repository
|
||||
func DeleteRepo(ctx *context.Context) {
|
||||
repo, err := models.GetRepositoryByID(ctx.QueryInt64("id"))
|
||||
repo, err := models.GetRepositoryByID(ctx.FormInt64("id"))
|
||||
if err != nil {
|
||||
ctx.ServerError("GetRepositoryByID", err)
|
||||
return
|
||||
@@ -59,7 +59,7 @@ func DeleteRepo(ctx *context.Context) {
|
||||
|
||||
ctx.Flash.Success(ctx.Tr("repo.settings.deletion_success"))
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"redirect": setting.AppSubURL + "/admin/repos?page=" + ctx.Query("page") + "&sort=" + ctx.Query("sort"),
|
||||
"redirect": setting.AppSubURL + "/admin/repos?page=" + ctx.Form("page") + "&sort=" + ctx.Form("sort"),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ func UnadoptedRepos(ctx *context.Context) {
|
||||
|
||||
opts := models.ListOptions{
|
||||
PageSize: setting.UI.Admin.UserPagingNum,
|
||||
Page: ctx.QueryInt("page"),
|
||||
Page: ctx.FormInt("page"),
|
||||
}
|
||||
|
||||
if opts.Page <= 0 {
|
||||
@@ -80,10 +80,10 @@ func UnadoptedRepos(ctx *context.Context) {
|
||||
|
||||
ctx.Data["CurrentPage"] = opts.Page
|
||||
|
||||
doSearch := ctx.QueryBool("search")
|
||||
doSearch := ctx.FormBool("search")
|
||||
|
||||
ctx.Data["search"] = doSearch
|
||||
q := ctx.Query("q")
|
||||
q := ctx.Form("q")
|
||||
|
||||
if !doSearch {
|
||||
pager := context.NewPagination(0, opts.PageSize, opts.Page, 5)
|
||||
@@ -109,10 +109,10 @@ func UnadoptedRepos(ctx *context.Context) {
|
||||
|
||||
// AdoptOrDeleteRepository adopts or deletes a repository
|
||||
func AdoptOrDeleteRepository(ctx *context.Context) {
|
||||
dir := ctx.Query("id")
|
||||
action := ctx.Query("action")
|
||||
page := ctx.QueryInt("page")
|
||||
q := ctx.Query("q")
|
||||
dir := ctx.Form("id")
|
||||
action := ctx.Form("action")
|
||||
page := ctx.FormInt("page")
|
||||
q := ctx.Form("q")
|
||||
|
||||
dirSplit := strings.SplitN(dir, "/", 2)
|
||||
if len(dirSplit) != 2 {
|
||||
|
Reference in New Issue
Block a user