mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Move modules/forms to services/forms (#15305)
Forms are dependent on models and therefore should be in services. This PR also removes the old auth. aliasing Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
@@ -15,7 +15,6 @@ import (
|
||||
"code.gitea.io/gitea/modules/base"
|
||||
"code.gitea.io/gitea/modules/charset"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
auth "code.gitea.io/gitea/modules/forms"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/repofiles"
|
||||
@@ -25,6 +24,7 @@ import (
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
"code.gitea.io/gitea/modules/web"
|
||||
"code.gitea.io/gitea/routers/utils"
|
||||
"code.gitea.io/gitea/services/forms"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
@@ -177,7 +177,7 @@ func NewFile(ctx *context.Context) {
|
||||
editFile(ctx, true)
|
||||
}
|
||||
|
||||
func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bool) {
|
||||
func editFilePost(ctx *context.Context, form forms.EditRepoFileForm, isNewFile bool) {
|
||||
canCommit := renderCommitRights(ctx)
|
||||
treeNames, treePaths := getParentTreeFields(form.TreePath)
|
||||
branchName := ctx.Repo.BranchName
|
||||
@@ -330,19 +330,19 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
|
||||
|
||||
// EditFilePost response for editing file
|
||||
func EditFilePost(ctx *context.Context) {
|
||||
form := web.GetForm(ctx).(*auth.EditRepoFileForm)
|
||||
form := web.GetForm(ctx).(*forms.EditRepoFileForm)
|
||||
editFilePost(ctx, *form, false)
|
||||
}
|
||||
|
||||
// NewFilePost response for creating file
|
||||
func NewFilePost(ctx *context.Context) {
|
||||
form := web.GetForm(ctx).(*auth.EditRepoFileForm)
|
||||
form := web.GetForm(ctx).(*forms.EditRepoFileForm)
|
||||
editFilePost(ctx, *form, true)
|
||||
}
|
||||
|
||||
// DiffPreviewPost render preview diff page
|
||||
func DiffPreviewPost(ctx *context.Context) {
|
||||
form := web.GetForm(ctx).(*auth.EditPreviewDiffForm)
|
||||
form := web.GetForm(ctx).(*forms.EditPreviewDiffForm)
|
||||
treePath := cleanUploadFileName(ctx.Repo.TreePath)
|
||||
if len(treePath) == 0 {
|
||||
ctx.Error(http.StatusInternalServerError, "file name to diff is invalid")
|
||||
@@ -402,7 +402,7 @@ func DeleteFile(ctx *context.Context) {
|
||||
|
||||
// DeleteFilePost response for deleting file
|
||||
func DeleteFilePost(ctx *context.Context) {
|
||||
form := web.GetForm(ctx).(*auth.DeleteRepoFileForm)
|
||||
form := web.GetForm(ctx).(*forms.DeleteRepoFileForm)
|
||||
canCommit := renderCommitRights(ctx)
|
||||
branchName := ctx.Repo.BranchName
|
||||
if form.CommitChoice == frmCommitChoiceNewBranch {
|
||||
@@ -566,7 +566,7 @@ func UploadFile(ctx *context.Context) {
|
||||
|
||||
// UploadFilePost response for uploading file
|
||||
func UploadFilePost(ctx *context.Context) {
|
||||
form := web.GetForm(ctx).(*auth.UploadRepoFileForm)
|
||||
form := web.GetForm(ctx).(*forms.UploadRepoFileForm)
|
||||
ctx.Data["PageIsUpload"] = true
|
||||
ctx.Data["RequireTribute"] = true
|
||||
ctx.Data["RequireSimpleMDE"] = true
|
||||
@@ -772,7 +772,7 @@ func UploadFileToServer(ctx *context.Context) {
|
||||
|
||||
// RemoveUploadFileFromServer remove file from server file dir
|
||||
func RemoveUploadFileFromServer(ctx *context.Context) {
|
||||
form := web.GetForm(ctx).(*auth.RemoveUploadFileForm)
|
||||
form := web.GetForm(ctx).(*forms.RemoveUploadFileForm)
|
||||
if len(form.File) == 0 {
|
||||
ctx.Status(204)
|
||||
return
|
||||
|
Reference in New Issue
Block a user