[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
|
@ -5,6 +5,7 @@
|
|||
package repo
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
|
@ -64,7 +65,7 @@ func Activity(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
ctx.HTML(200, tplActivity)
|
||||
ctx.HTML(http.StatusOK, tplActivity)
|
||||
}
|
||||
|
||||
// ActivityAuthors renders JSON with top commit authors for given time period over all branches
|
||||
|
@ -98,5 +99,5 @@ func ActivityAuthors(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
ctx.JSON(200, authors)
|
||||
ctx.JSON(http.StatusOK, authors)
|
||||
}
|
||||
|
|
|
@ -29,13 +29,13 @@ func UploadReleaseAttachment(ctx *context.Context) {
|
|||
// UploadAttachment response for uploading attachments
|
||||
func uploadAttachment(ctx *context.Context, allowedTypes string) {
|
||||
if !setting.Attachment.Enabled {
|
||||
ctx.Error(404, "attachment is not enabled")
|
||||
ctx.Error(http.StatusNotFound, "attachment is not enabled")
|
||||
return
|
||||
}
|
||||
|
||||
file, header, err := ctx.Req.FormFile("file")
|
||||
if err != nil {
|
||||
ctx.Error(500, fmt.Sprintf("FormFile: %v", err))
|
||||
ctx.Error(http.StatusInternalServerError, fmt.Sprintf("FormFile: %v", err))
|
||||
return
|
||||
}
|
||||
defer file.Close()
|
||||
|
@ -48,7 +48,7 @@ func uploadAttachment(ctx *context.Context, allowedTypes string) {
|
|||
|
||||
err = upload.Verify(buf, header.Filename, allowedTypes)
|
||||
if err != nil {
|
||||
ctx.Error(400, err.Error())
|
||||
ctx.Error(http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -57,12 +57,12 @@ func uploadAttachment(ctx *context.Context, allowedTypes string) {
|
|||
Name: header.Filename,
|
||||
}, buf, file)
|
||||
if err != nil {
|
||||
ctx.Error(500, fmt.Sprintf("NewAttachment: %v", err))
|
||||
ctx.Error(http.StatusInternalServerError, fmt.Sprintf("NewAttachment: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
log.Trace("New attachment uploaded: %s", attach.UUID)
|
||||
ctx.JSON(200, map[string]string{
|
||||
ctx.JSON(http.StatusOK, map[string]string{
|
||||
"uuid": attach.UUID,
|
||||
})
|
||||
}
|
||||
|
@ -72,19 +72,19 @@ func DeleteAttachment(ctx *context.Context) {
|
|||
file := ctx.Query("file")
|
||||
attach, err := models.GetAttachmentByUUID(file)
|
||||
if err != nil {
|
||||
ctx.Error(400, err.Error())
|
||||
ctx.Error(http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
if !ctx.IsSigned || (ctx.User.ID != attach.UploaderID) {
|
||||
ctx.Error(403)
|
||||
ctx.Error(http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
err = models.DeleteAttachment(attach, true)
|
||||
if err != nil {
|
||||
ctx.Error(500, fmt.Sprintf("DeleteAttachment: %v", err))
|
||||
ctx.Error(http.StatusInternalServerError, fmt.Sprintf("DeleteAttachment: %v", err))
|
||||
return
|
||||
}
|
||||
ctx.JSON(200, map[string]string{
|
||||
ctx.JSON(http.StatusOK, map[string]string{
|
||||
"uuid": attach.UUID,
|
||||
})
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ func GetAttachment(ctx *context.Context) {
|
|||
attach, err := models.GetAttachmentByUUID(ctx.Params(":uuid"))
|
||||
if err != nil {
|
||||
if models.IsErrAttachmentNotExist(err) {
|
||||
ctx.Error(404)
|
||||
ctx.Error(http.StatusNotFound)
|
||||
} else {
|
||||
ctx.ServerError("GetAttachmentByUUID", err)
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
"fmt"
|
||||
"html"
|
||||
gotemplate "html/template"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
|
@ -184,7 +185,7 @@ func RefBlame(ctx *context.Context) {
|
|||
|
||||
renderBlame(ctx, blameParts, commitNames)
|
||||
|
||||
ctx.HTML(200, tplBlame)
|
||||
ctx.HTML(http.StatusOK, tplBlame)
|
||||
}
|
||||
|
||||
func renderBlame(ctx *context.Context, blameParts []git.BlamePart, commitNames map[string]models.UserCommit) {
|
||||
|
|
|
@ -7,6 +7,7 @@ package repo
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
|
@ -75,7 +76,7 @@ func Branches(ctx *context.Context) {
|
|||
pager.SetDefaultParams(ctx)
|
||||
ctx.Data["Page"] = pager
|
||||
|
||||
ctx.HTML(200, tplBranch)
|
||||
ctx.HTML(http.StatusOK, tplBranch)
|
||||
}
|
||||
|
||||
// DeleteBranchPost responses for delete merged branch
|
||||
|
@ -163,7 +164,7 @@ func RestoreBranchPost(ctx *context.Context) {
|
|||
}
|
||||
|
||||
func redirect(ctx *context.Context) {
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"redirect": ctx.Repo.RepoLink + "/branches",
|
||||
})
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ package repo
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
|
@ -85,7 +86,7 @@ func Commits(ctx *context.Context) {
|
|||
pager.SetDefaultParams(ctx)
|
||||
ctx.Data["Page"] = pager
|
||||
|
||||
ctx.HTML(200, tplCommits)
|
||||
ctx.HTML(http.StatusOK, tplCommits)
|
||||
}
|
||||
|
||||
// Graph render commit graph - show commits from all branches.
|
||||
|
@ -167,11 +168,11 @@ func Graph(ctx *context.Context) {
|
|||
}
|
||||
ctx.Data["Page"] = paginator
|
||||
if ctx.QueryBool("div-only") {
|
||||
ctx.HTML(200, tplGraphDiv)
|
||||
ctx.HTML(http.StatusOK, tplGraphDiv)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.HTML(200, tplGraph)
|
||||
ctx.HTML(http.StatusOK, tplGraph)
|
||||
}
|
||||
|
||||
// SearchCommits render commits filtered by keyword
|
||||
|
@ -205,7 +206,7 @@ func SearchCommits(ctx *context.Context) {
|
|||
ctx.Data["Reponame"] = ctx.Repo.Repository.Name
|
||||
ctx.Data["CommitCount"] = commits.Len()
|
||||
ctx.Data["Branch"] = ctx.Repo.BranchName
|
||||
ctx.HTML(200, tplCommits)
|
||||
ctx.HTML(http.StatusOK, tplCommits)
|
||||
}
|
||||
|
||||
// FileHistory show a file's reversions
|
||||
|
@ -253,7 +254,7 @@ func FileHistory(ctx *context.Context) {
|
|||
pager.SetDefaultParams(ctx)
|
||||
ctx.Data["Page"] = pager
|
||||
|
||||
ctx.HTML(200, tplCommits)
|
||||
ctx.HTML(http.StatusOK, tplCommits)
|
||||
}
|
||||
|
||||
// Diff show different from current commit to previous commit
|
||||
|
@ -372,7 +373,7 @@ func Diff(ctx *context.Context) {
|
|||
ctx.ServerError("commit.GetTagName", err)
|
||||
return
|
||||
}
|
||||
ctx.HTML(200, tplCommitPage)
|
||||
ctx.HTML(http.StatusOK, tplCommitPage)
|
||||
}
|
||||
|
||||
// RawDiff dumps diff results of repository in given commit ID to io.Writer
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
"fmt"
|
||||
"html"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
@ -632,7 +633,7 @@ func CompareDiff(ctx *context.Context) {
|
|||
} else {
|
||||
ctx.Data["HasPullRequest"] = true
|
||||
ctx.Data["PullRequest"] = pr
|
||||
ctx.HTML(200, tplCompareDiff)
|
||||
ctx.HTML(http.StatusOK, tplCompareDiff)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -660,7 +661,7 @@ func CompareDiff(ctx *context.Context) {
|
|||
|
||||
ctx.Data["HasIssuesOrPullsWritePermission"] = ctx.Repo.CanWrite(models.UnitTypePullRequests)
|
||||
|
||||
ctx.HTML(200, tplCompare)
|
||||
ctx.HTML(http.StatusOK, tplCompare)
|
||||
}
|
||||
|
||||
// ExcerptBlob render blob excerpt contents
|
||||
|
@ -679,7 +680,7 @@ func ExcerptBlob(ctx *context.Context) {
|
|||
chunkSize := gitdiff.BlobExcerptChunkSize
|
||||
commit, err := gitRepo.GetCommit(commitID)
|
||||
if err != nil {
|
||||
ctx.Error(500, "GetCommit")
|
||||
ctx.Error(http.StatusInternalServerError, "GetCommit")
|
||||
return
|
||||
}
|
||||
section := &gitdiff.DiffSection{
|
||||
|
@ -704,7 +705,7 @@ func ExcerptBlob(ctx *context.Context) {
|
|||
idxRight = lastRight
|
||||
}
|
||||
if err != nil {
|
||||
ctx.Error(500, "getExcerptLines")
|
||||
ctx.Error(http.StatusInternalServerError, "getExcerptLines")
|
||||
return
|
||||
}
|
||||
if idxRight > lastRight {
|
||||
|
@ -735,7 +736,7 @@ func ExcerptBlob(ctx *context.Context) {
|
|||
ctx.Data["fileName"] = filePath
|
||||
ctx.Data["AfterCommitID"] = commitID
|
||||
ctx.Data["Anchor"] = anchor
|
||||
ctx.HTML(200, tplBlobExcerpt)
|
||||
ctx.HTML(http.StatusOK, tplBlobExcerpt)
|
||||
}
|
||||
|
||||
func getExcerptLines(commit *git.Commit, filePath string, idxLeft int, idxRight int, chunkSize int) ([]*gitdiff.DiffLine, error) {
|
||||
|
|
|
@ -7,6 +7,7 @@ package repo
|
|||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
|
@ -149,7 +150,7 @@ func editFile(ctx *context.Context, isNewFile bool) {
|
|||
ctx.Data["PreviewableFileModes"] = strings.Join(setting.Repository.Editor.PreviewableFileModes, ",")
|
||||
ctx.Data["Editorconfig"] = GetEditorConfig(ctx, treePath)
|
||||
|
||||
ctx.HTML(200, tplEditFile)
|
||||
ctx.HTML(http.StatusOK, tplEditFile)
|
||||
}
|
||||
|
||||
// GetEditorConfig returns a editorconfig JSON string for given treePath or "null"
|
||||
|
@ -205,7 +206,7 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
|
|||
ctx.Data["Editorconfig"] = GetEditorConfig(ctx, form.TreePath)
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, tplEditFile)
|
||||
ctx.HTML(http.StatusOK, tplEditFile)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -263,10 +264,10 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
|
|||
case git.EntryModeBlob:
|
||||
ctx.RenderWithErr(ctx.Tr("repo.editor.directory_is_a_file", fileErr.Path), tplEditFile, &form)
|
||||
default:
|
||||
ctx.Error(500, err.Error())
|
||||
ctx.Error(http.StatusInternalServerError, err.Error())
|
||||
}
|
||||
} else {
|
||||
ctx.Error(500, err.Error())
|
||||
ctx.Error(http.StatusInternalServerError, err.Error())
|
||||
}
|
||||
} else if models.IsErrRepoFileAlreadyExists(err) {
|
||||
ctx.Data["Err_TreePath"] = true
|
||||
|
@ -276,7 +277,7 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
|
|||
if branchErr, ok := err.(git.ErrBranchNotExist); ok {
|
||||
ctx.RenderWithErr(ctx.Tr("repo.editor.branch_does_not_exist", branchErr.Name), tplEditFile, &form)
|
||||
} else {
|
||||
ctx.Error(500, err.Error())
|
||||
ctx.Error(http.StatusInternalServerError, err.Error())
|
||||
}
|
||||
} else if models.IsErrBranchAlreadyExists(err) {
|
||||
// For when a user specifies a new branch that already exists
|
||||
|
@ -284,7 +285,7 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
|
|||
if branchErr, ok := err.(models.ErrBranchAlreadyExists); ok {
|
||||
ctx.RenderWithErr(ctx.Tr("repo.editor.branch_already_exists", branchErr.BranchName), tplEditFile, &form)
|
||||
} else {
|
||||
ctx.Error(500, err.Error())
|
||||
ctx.Error(http.StatusInternalServerError, err.Error())
|
||||
}
|
||||
} else if models.IsErrCommitIDDoesNotMatch(err) {
|
||||
ctx.RenderWithErr(ctx.Tr("repo.editor.file_changed_while_editing", ctx.Repo.RepoLink+"/compare/"+form.LastCommit+"..."+ctx.Repo.CommitID), tplEditFile, &form)
|
||||
|
@ -344,22 +345,22 @@ func DiffPreviewPost(ctx *context.Context) {
|
|||
form := web.GetForm(ctx).(*auth.EditPreviewDiffForm)
|
||||
treePath := cleanUploadFileName(ctx.Repo.TreePath)
|
||||
if len(treePath) == 0 {
|
||||
ctx.Error(500, "file name to diff is invalid")
|
||||
ctx.Error(http.StatusInternalServerError, "file name to diff is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
entry, err := ctx.Repo.Commit.GetTreeEntryByPath(treePath)
|
||||
if err != nil {
|
||||
ctx.Error(500, "GetTreeEntryByPath: "+err.Error())
|
||||
ctx.Error(http.StatusInternalServerError, "GetTreeEntryByPath: "+err.Error())
|
||||
return
|
||||
} else if entry.IsDir() {
|
||||
ctx.Error(422)
|
||||
ctx.Error(http.StatusUnprocessableEntity)
|
||||
return
|
||||
}
|
||||
|
||||
diff, err := repofiles.GetDiffPreview(ctx.Repo.Repository, ctx.Repo.BranchName, treePath, form.Content)
|
||||
if err != nil {
|
||||
ctx.Error(500, "GetDiffPreview: "+err.Error())
|
||||
ctx.Error(http.StatusInternalServerError, "GetDiffPreview: "+err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -369,7 +370,7 @@ func DiffPreviewPost(ctx *context.Context) {
|
|||
}
|
||||
ctx.Data["File"] = diff.Files[0]
|
||||
|
||||
ctx.HTML(200, tplEditDiffPreview)
|
||||
ctx.HTML(http.StatusOK, tplEditDiffPreview)
|
||||
}
|
||||
|
||||
// DeleteFile render delete file page
|
||||
|
@ -396,7 +397,7 @@ func DeleteFile(ctx *context.Context) {
|
|||
}
|
||||
ctx.Data["new_branch_name"] = GetUniquePatchBranchName(ctx)
|
||||
|
||||
ctx.HTML(200, tplDeleteFile)
|
||||
ctx.HTML(http.StatusOK, tplDeleteFile)
|
||||
}
|
||||
|
||||
// DeleteFilePost response for deleting file
|
||||
|
@ -418,7 +419,7 @@ func DeleteFilePost(ctx *context.Context) {
|
|||
ctx.Data["last_commit"] = ctx.Repo.CommitID
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, tplDeleteFile)
|
||||
ctx.HTML(http.StatusOK, tplDeleteFile)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -473,14 +474,14 @@ func DeleteFilePost(ctx *context.Context) {
|
|||
if branchErr, ok := err.(git.ErrBranchNotExist); ok {
|
||||
ctx.RenderWithErr(ctx.Tr("repo.editor.branch_does_not_exist", branchErr.Name), tplDeleteFile, &form)
|
||||
} else {
|
||||
ctx.Error(500, err.Error())
|
||||
ctx.Error(http.StatusInternalServerError, err.Error())
|
||||
}
|
||||
} else if models.IsErrBranchAlreadyExists(err) {
|
||||
// For when a user specifies a new branch that already exists
|
||||
if branchErr, ok := err.(models.ErrBranchAlreadyExists); ok {
|
||||
ctx.RenderWithErr(ctx.Tr("repo.editor.branch_already_exists", branchErr.BranchName), tplDeleteFile, &form)
|
||||
} else {
|
||||
ctx.Error(500, err.Error())
|
||||
ctx.Error(http.StatusInternalServerError, err.Error())
|
||||
}
|
||||
} else if models.IsErrCommitIDDoesNotMatch(err) || git.IsErrPushOutOfDate(err) {
|
||||
ctx.RenderWithErr(ctx.Tr("repo.editor.file_changed_while_deleting", ctx.Repo.RepoLink+"/compare/"+form.LastCommit+"..."+ctx.Repo.CommitID), tplDeleteFile, &form)
|
||||
|
@ -560,7 +561,7 @@ func UploadFile(ctx *context.Context) {
|
|||
}
|
||||
ctx.Data["new_branch_name"] = GetUniquePatchBranchName(ctx)
|
||||
|
||||
ctx.HTML(200, tplUploadFile)
|
||||
ctx.HTML(http.StatusOK, tplUploadFile)
|
||||
}
|
||||
|
||||
// UploadFilePost response for uploading file
|
||||
|
@ -597,7 +598,7 @@ func UploadFilePost(ctx *context.Context) {
|
|||
ctx.Data["new_branch_name"] = branchName
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, tplUploadFile)
|
||||
ctx.HTML(http.StatusOK, tplUploadFile)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -672,7 +673,7 @@ func UploadFilePost(ctx *context.Context) {
|
|||
case git.EntryModeBlob:
|
||||
ctx.RenderWithErr(ctx.Tr("repo.editor.directory_is_a_file", fileErr.Path), tplUploadFile, &form)
|
||||
default:
|
||||
ctx.Error(500, err.Error())
|
||||
ctx.Error(http.StatusInternalServerError, err.Error())
|
||||
}
|
||||
} else if models.IsErrRepoFileAlreadyExists(err) {
|
||||
ctx.Data["Err_TreePath"] = true
|
||||
|
@ -734,7 +735,7 @@ func cleanUploadFileName(name string) string {
|
|||
func UploadFileToServer(ctx *context.Context) {
|
||||
file, header, err := ctx.Req.FormFile("file")
|
||||
if err != nil {
|
||||
ctx.Error(500, fmt.Sprintf("FormFile: %v", err))
|
||||
ctx.Error(http.StatusInternalServerError, fmt.Sprintf("FormFile: %v", err))
|
||||
return
|
||||
}
|
||||
defer file.Close()
|
||||
|
@ -747,24 +748,24 @@ func UploadFileToServer(ctx *context.Context) {
|
|||
|
||||
err = upload.Verify(buf, header.Filename, setting.Repository.Upload.AllowedTypes)
|
||||
if err != nil {
|
||||
ctx.Error(400, err.Error())
|
||||
ctx.Error(http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
name := cleanUploadFileName(header.Filename)
|
||||
if len(name) == 0 {
|
||||
ctx.Error(500, "Upload file name is invalid")
|
||||
ctx.Error(http.StatusInternalServerError, "Upload file name is invalid")
|
||||
return
|
||||
}
|
||||
|
||||
upload, err := models.NewUpload(name, buf, file)
|
||||
if err != nil {
|
||||
ctx.Error(500, fmt.Sprintf("NewUpload: %v", err))
|
||||
ctx.Error(http.StatusInternalServerError, fmt.Sprintf("NewUpload: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
log.Trace("New file uploaded: %s", upload.UUID)
|
||||
ctx.JSON(200, map[string]string{
|
||||
ctx.JSON(http.StatusOK, map[string]string{
|
||||
"uuid": upload.UUID,
|
||||
})
|
||||
}
|
||||
|
@ -778,7 +779,7 @@ func RemoveUploadFileFromServer(ctx *context.Context) {
|
|||
}
|
||||
|
||||
if err := models.DeleteUploadByUUID(form.File); err != nil {
|
||||
ctx.Error(500, fmt.Sprintf("DeleteUploadByUUID: %v", err))
|
||||
ctx.Error(http.StatusInternalServerError, fmt.Sprintf("DeleteUploadByUUID: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -393,7 +393,7 @@ func Issues(ctx *context.Context) {
|
|||
|
||||
ctx.Data["CanWriteIssuesOrPulls"] = ctx.Repo.CanWriteIssuesOrPulls(isPullList)
|
||||
|
||||
ctx.HTML(200, tplIssues)
|
||||
ctx.HTML(http.StatusOK, tplIssues)
|
||||
}
|
||||
|
||||
// RetrieveRepoMilestonesAndAssignees find all the milestones and assignees of a repository
|
||||
|
@ -819,7 +819,7 @@ func NewIssue(ctx *context.Context) {
|
|||
|
||||
ctx.Data["HasIssuesOrPullsWritePermission"] = ctx.Repo.CanWrite(models.UnitTypeIssues)
|
||||
|
||||
ctx.HTML(200, tplIssueNew)
|
||||
ctx.HTML(http.StatusOK, tplIssueNew)
|
||||
}
|
||||
|
||||
// NewIssueChooseTemplate render creating issue from template page
|
||||
|
@ -832,7 +832,7 @@ func NewIssueChooseTemplate(ctx *context.Context) {
|
|||
ctx.Data["NewIssueChooseTemplate"] = len(issueTemplates) > 0
|
||||
ctx.Data["IssueTemplates"] = issueTemplates
|
||||
|
||||
ctx.HTML(200, tplIssueChoose)
|
||||
ctx.HTML(http.StatusOK, tplIssueChoose)
|
||||
}
|
||||
|
||||
// ValidateRepoMetas check and returns repository's meta informations
|
||||
|
@ -960,7 +960,7 @@ func NewIssuePost(ctx *context.Context) {
|
|||
}
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, tplIssueNew)
|
||||
ctx.HTML(http.StatusOK, tplIssueNew)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -981,7 +981,7 @@ func NewIssuePost(ctx *context.Context) {
|
|||
|
||||
if err := issue_service.NewIssue(repo, issue, labelIDs, attachments, assigneeIDs); err != nil {
|
||||
if models.IsErrUserDoesNotHaveAccessToRepo(err) {
|
||||
ctx.Error(400, "UserDoesNotHaveAccessToRepo", err.Error())
|
||||
ctx.Error(http.StatusBadRequest, "UserDoesNotHaveAccessToRepo", err.Error())
|
||||
return
|
||||
}
|
||||
ctx.ServerError("NewIssue", err)
|
||||
|
@ -1578,7 +1578,7 @@ func ViewIssue(ctx *context.Context) {
|
|||
ctx.Data["IsRepoAdmin"] = ctx.IsSigned && (ctx.Repo.IsAdmin() || ctx.User.IsAdmin)
|
||||
ctx.Data["LockReasons"] = setting.Repository.Issue.LockReasons
|
||||
ctx.Data["RefEndName"] = git.RefEndName(issue.Ref)
|
||||
ctx.HTML(200, tplIssueView)
|
||||
ctx.HTML(http.StatusOK, tplIssueView)
|
||||
}
|
||||
|
||||
// GetActionIssue will return the issue which is used in the context.
|
||||
|
@ -1650,13 +1650,13 @@ func UpdateIssueTitle(ctx *context.Context) {
|
|||
}
|
||||
|
||||
if !ctx.IsSigned || (!issue.IsPoster(ctx.User.ID) && !ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)) {
|
||||
ctx.Error(403)
|
||||
ctx.Error(http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
title := ctx.QueryTrim("title")
|
||||
if len(title) == 0 {
|
||||
ctx.Error(204)
|
||||
ctx.Error(http.StatusNoContent)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1665,7 +1665,7 @@ func UpdateIssueTitle(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"title": issue.Title,
|
||||
})
|
||||
}
|
||||
|
@ -1678,7 +1678,7 @@ func UpdateIssueRef(ctx *context.Context) {
|
|||
}
|
||||
|
||||
if !ctx.IsSigned || (!issue.IsPoster(ctx.User.ID) && !ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)) || issue.IsPull {
|
||||
ctx.Error(403)
|
||||
ctx.Error(http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1689,7 +1689,7 @@ func UpdateIssueRef(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"ref": ref,
|
||||
})
|
||||
}
|
||||
|
@ -1702,7 +1702,7 @@ func UpdateIssueContent(ctx *context.Context) {
|
|||
}
|
||||
|
||||
if !ctx.IsSigned || (ctx.User.ID != issue.PosterID && !ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)) {
|
||||
ctx.Error(403)
|
||||
ctx.Error(http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1717,7 +1717,7 @@ func UpdateIssueContent(ctx *context.Context) {
|
|||
ctx.ServerError("UpdateAttachments", err)
|
||||
}
|
||||
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"content": string(markdown.Render([]byte(issue.Content), ctx.Query("context"), ctx.Repo.Repository.ComposeMetas())),
|
||||
"attachments": attachmentsHTML(ctx, issue.Attachments, issue.Content),
|
||||
})
|
||||
|
@ -1743,7 +1743,7 @@ func UpdateIssueMilestone(ctx *context.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"ok": true,
|
||||
})
|
||||
}
|
||||
|
@ -1789,7 +1789,7 @@ func UpdateIssueAssignee(ctx *context.Context) {
|
|||
}
|
||||
}
|
||||
}
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"ok": true,
|
||||
})
|
||||
}
|
||||
|
@ -1914,7 +1914,7 @@ func UpdatePullReviewRequest(ctx *context.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"ok": true,
|
||||
})
|
||||
}
|
||||
|
@ -1954,7 +1954,7 @@ func UpdateIssueStatus(ctx *context.Context) {
|
|||
}
|
||||
}
|
||||
}
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"ok": true,
|
||||
})
|
||||
}
|
||||
|
@ -1986,7 +1986,7 @@ func NewComment(ctx *context.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
ctx.Error(403)
|
||||
ctx.Error(http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -2109,17 +2109,17 @@ func UpdateCommentContent(ctx *context.Context) {
|
|||
}
|
||||
|
||||
if !ctx.IsSigned || (ctx.User.ID != comment.PosterID && !ctx.Repo.CanWriteIssuesOrPulls(comment.Issue.IsPull)) {
|
||||
ctx.Error(403)
|
||||
ctx.Error(http.StatusForbidden)
|
||||
return
|
||||
} else if comment.Type != models.CommentTypeComment && comment.Type != models.CommentTypeCode {
|
||||
ctx.Error(204)
|
||||
ctx.Error(http.StatusNoContent)
|
||||
return
|
||||
}
|
||||
|
||||
oldContent := comment.Content
|
||||
comment.Content = ctx.Query("content")
|
||||
if len(comment.Content) == 0 {
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"content": "",
|
||||
})
|
||||
return
|
||||
|
@ -2134,7 +2134,7 @@ func UpdateCommentContent(ctx *context.Context) {
|
|||
ctx.ServerError("UpdateAttachments", err)
|
||||
}
|
||||
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"content": string(markdown.Render([]byte(comment.Content), ctx.Query("context"), ctx.Repo.Repository.ComposeMetas())),
|
||||
"attachments": attachmentsHTML(ctx, comment.Attachments, comment.Content),
|
||||
})
|
||||
|
@ -2154,10 +2154,10 @@ func DeleteComment(ctx *context.Context) {
|
|||
}
|
||||
|
||||
if !ctx.IsSigned || (ctx.User.ID != comment.PosterID && !ctx.Repo.CanWriteIssuesOrPulls(comment.Issue.IsPull)) {
|
||||
ctx.Error(403)
|
||||
ctx.Error(http.StatusForbidden)
|
||||
return
|
||||
} else if comment.Type != models.CommentTypeComment && comment.Type != models.CommentTypeCode {
|
||||
ctx.Error(204)
|
||||
ctx.Error(http.StatusNoContent)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -2196,7 +2196,7 @@ func ChangeIssueReaction(ctx *context.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
ctx.Error(403)
|
||||
ctx.Error(http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -2244,7 +2244,7 @@ func ChangeIssueReaction(ctx *context.Context) {
|
|||
}
|
||||
|
||||
if len(issue.Reactions) == 0 {
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"empty": true,
|
||||
"html": "",
|
||||
})
|
||||
|
@ -2260,7 +2260,7 @@ func ChangeIssueReaction(ctx *context.Context) {
|
|||
ctx.ServerError("ChangeIssueReaction.HTMLString", err)
|
||||
return
|
||||
}
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"html": html,
|
||||
})
|
||||
}
|
||||
|
@ -2298,10 +2298,10 @@ func ChangeCommentReaction(ctx *context.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
ctx.Error(403)
|
||||
ctx.Error(http.StatusForbidden)
|
||||
return
|
||||
} else if comment.Type != models.CommentTypeComment && comment.Type != models.CommentTypeCode {
|
||||
ctx.Error(204)
|
||||
ctx.Error(http.StatusNoContent)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -2344,7 +2344,7 @@ func ChangeCommentReaction(ctx *context.Context) {
|
|||
}
|
||||
|
||||
if len(comment.Reactions) == 0 {
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"empty": true,
|
||||
"html": "",
|
||||
})
|
||||
|
@ -2360,7 +2360,7 @@ func ChangeCommentReaction(ctx *context.Context) {
|
|||
ctx.ServerError("ChangeCommentReaction.HTMLString", err)
|
||||
return
|
||||
}
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"html": html,
|
||||
})
|
||||
}
|
||||
|
@ -2406,7 +2406,7 @@ func GetIssueAttachments(ctx *context.Context) {
|
|||
for i := 0; i < len(issue.Attachments); i++ {
|
||||
attachments[i] = convert.ToReleaseAttachment(issue.Attachments[i])
|
||||
}
|
||||
ctx.JSON(200, attachments)
|
||||
ctx.JSON(http.StatusOK, attachments)
|
||||
}
|
||||
|
||||
// GetCommentAttachments returns attachments for the comment
|
||||
|
@ -2426,7 +2426,7 @@ func GetCommentAttachments(ctx *context.Context) {
|
|||
attachments = append(attachments, convert.ToReleaseAttachment(comment.Attachments[i]))
|
||||
}
|
||||
}
|
||||
ctx.JSON(200, attachments)
|
||||
ctx.JSON(http.StatusOK, attachments)
|
||||
}
|
||||
|
||||
func updateAttachments(item interface{}, files []string) error {
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
package repo
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/base"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
|
@ -26,7 +28,7 @@ func Labels(ctx *context.Context) {
|
|||
ctx.Data["PageIsLabels"] = true
|
||||
ctx.Data["RequireTribute"] = true
|
||||
ctx.Data["LabelTemplates"] = models.LabelTemplates
|
||||
ctx.HTML(200, tplLabels)
|
||||
ctx.HTML(http.StatusOK, tplLabels)
|
||||
}
|
||||
|
||||
// InitializeLabels init labels for a repository
|
||||
|
@ -127,7 +129,7 @@ func UpdateLabel(ctx *context.Context) {
|
|||
if err != nil {
|
||||
switch {
|
||||
case models.IsErrRepoLabelNotExist(err):
|
||||
ctx.Error(404)
|
||||
ctx.Error(http.StatusNotFound)
|
||||
default:
|
||||
ctx.ServerError("UpdateLabel", err)
|
||||
}
|
||||
|
@ -152,7 +154,7 @@ func DeleteLabel(ctx *context.Context) {
|
|||
ctx.Flash.Success(ctx.Tr("repo.issues.label_deletion_success"))
|
||||
}
|
||||
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"redirect": ctx.Repo.RepoLink + "/labels",
|
||||
})
|
||||
}
|
||||
|
@ -176,7 +178,7 @@ func UpdateIssueLabel(ctx *context.Context) {
|
|||
label, err := models.GetLabelByID(ctx.QueryInt64("id"))
|
||||
if err != nil {
|
||||
if models.IsErrRepoLabelNotExist(err) {
|
||||
ctx.Error(404, "GetLabelByID")
|
||||
ctx.Error(http.StatusNotFound, "GetLabelByID")
|
||||
} else {
|
||||
ctx.ServerError("GetLabelByID", err)
|
||||
}
|
||||
|
@ -211,11 +213,11 @@ func UpdateIssueLabel(ctx *context.Context) {
|
|||
}
|
||||
default:
|
||||
log.Warn("Unrecognized action: %s", action)
|
||||
ctx.Error(500)
|
||||
ctx.Error(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"ok": true,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ func IssueWatch(ctx *context.Context) {
|
|||
log.Trace("Permission Denied: Not logged in")
|
||||
}
|
||||
}
|
||||
ctx.Error(403)
|
||||
ctx.Error(http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
gotemplate "html/template"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"path"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
@ -63,7 +64,7 @@ func LFSFiles(ctx *context.Context) {
|
|||
}
|
||||
ctx.Data["LFSFiles"] = lfsMetaObjects
|
||||
ctx.Data["Page"] = pager
|
||||
ctx.HTML(200, tplSettingsLFS)
|
||||
ctx.HTML(http.StatusOK, tplSettingsLFS)
|
||||
}
|
||||
|
||||
// LFSLocks shows a repository's LFS locks
|
||||
|
@ -97,7 +98,7 @@ func LFSLocks(ctx *context.Context) {
|
|||
|
||||
if len(lfsLocks) == 0 {
|
||||
ctx.Data["Page"] = pager
|
||||
ctx.HTML(200, tplSettingsLFSLocks)
|
||||
ctx.HTML(http.StatusOK, tplSettingsLFSLocks)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -186,7 +187,7 @@ func LFSLocks(ctx *context.Context) {
|
|||
ctx.Data["Linkable"] = linkable
|
||||
|
||||
ctx.Data["Page"] = pager
|
||||
ctx.HTML(200, tplSettingsLFSLocks)
|
||||
ctx.HTML(http.StatusOK, tplSettingsLFSLocks)
|
||||
}
|
||||
|
||||
// LFSLockFile locks a file
|
||||
|
@ -339,7 +340,7 @@ func LFSFileGet(ctx *context.Context) {
|
|||
case base.IsImageFile(buf):
|
||||
ctx.Data["IsImageFile"] = true
|
||||
}
|
||||
ctx.HTML(200, tplSettingsLFSFile)
|
||||
ctx.HTML(http.StatusOK, tplSettingsLFSFile)
|
||||
}
|
||||
|
||||
// LFSDelete disassociates the provided oid from the repository and if the lfs file is no longer associated with any repositories - deletes it
|
||||
|
@ -404,7 +405,7 @@ func LFSFileFind(ctx *context.Context) {
|
|||
}
|
||||
|
||||
ctx.Data["Results"] = results
|
||||
ctx.HTML(200, tplSettingsLFSFileFind)
|
||||
ctx.HTML(http.StatusOK, tplSettingsLFSFileFind)
|
||||
}
|
||||
|
||||
// LFSPointerFiles will search the repository for pointer files and report which are missing LFS files in the content store
|
||||
|
@ -478,7 +479,7 @@ func LFSPointerFiles(ctx *context.Context) {
|
|||
}
|
||||
default:
|
||||
}
|
||||
ctx.HTML(200, tplSettingsLFSPointers)
|
||||
ctx.HTML(http.StatusOK, tplSettingsLFSPointers)
|
||||
}
|
||||
|
||||
type pointerResult struct {
|
||||
|
|
|
@ -41,7 +41,7 @@ func Migrate(ctx *context.Context) {
|
|||
ctx.Data["Org"] = ctx.Query("org")
|
||||
ctx.Data["Mirror"] = ctx.Query("mirror")
|
||||
|
||||
ctx.HTML(200, tplMigrate)
|
||||
ctx.HTML(http.StatusOK, tplMigrate)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ func Migrate(ctx *context.Context) {
|
|||
}
|
||||
ctx.Data["ContextUser"] = ctxUser
|
||||
|
||||
ctx.HTML(200, base.TplName("repo/migrate/"+serviceType.Name()))
|
||||
ctx.HTML(http.StatusOK, base.TplName("repo/migrate/"+serviceType.Name()))
|
||||
}
|
||||
|
||||
func handleMigrateError(ctx *context.Context, owner *models.User, err error, name string, tpl base.TplName, form *auth.MigrateRepoForm) {
|
||||
|
@ -135,7 +135,7 @@ func MigratePost(ctx *context.Context) {
|
|||
tpl := base.TplName("repo/migrate/" + serviceType.Name())
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, tpl)
|
||||
ctx.HTML(http.StatusOK, tpl)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
package repo
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
|
@ -95,7 +96,7 @@ func Milestones(ctx *context.Context) {
|
|||
pager.AddParam(ctx, "state", "State")
|
||||
ctx.Data["Page"] = pager
|
||||
|
||||
ctx.HTML(200, tplMilestone)
|
||||
ctx.HTML(http.StatusOK, tplMilestone)
|
||||
}
|
||||
|
||||
// NewMilestone render creating milestone page
|
||||
|
@ -103,7 +104,7 @@ func NewMilestone(ctx *context.Context) {
|
|||
ctx.Data["Title"] = ctx.Tr("repo.milestones.new")
|
||||
ctx.Data["PageIsIssueList"] = true
|
||||
ctx.Data["PageIsMilestones"] = true
|
||||
ctx.HTML(200, tplMilestoneNew)
|
||||
ctx.HTML(http.StatusOK, tplMilestoneNew)
|
||||
}
|
||||
|
||||
// NewMilestonePost response for creating milestone
|
||||
|
@ -114,7 +115,7 @@ func NewMilestonePost(ctx *context.Context) {
|
|||
ctx.Data["PageIsMilestones"] = true
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, tplMilestoneNew)
|
||||
ctx.HTML(http.StatusOK, tplMilestoneNew)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -163,7 +164,7 @@ func EditMilestone(ctx *context.Context) {
|
|||
if len(m.DeadlineString) > 0 {
|
||||
ctx.Data["deadline"] = m.DeadlineString
|
||||
}
|
||||
ctx.HTML(200, tplMilestoneNew)
|
||||
ctx.HTML(http.StatusOK, tplMilestoneNew)
|
||||
}
|
||||
|
||||
// EditMilestonePost response for edting milestone
|
||||
|
@ -174,7 +175,7 @@ func EditMilestonePost(ctx *context.Context) {
|
|||
ctx.Data["PageIsEditMilestone"] = true
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, tplMilestoneNew)
|
||||
ctx.HTML(http.StatusOK, tplMilestoneNew)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -242,7 +243,7 @@ func DeleteMilestone(ctx *context.Context) {
|
|||
ctx.Flash.Success(ctx.Tr("repo.milestones.deletion_success"))
|
||||
}
|
||||
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"redirect": ctx.Repo.RepoLink + "/milestones",
|
||||
})
|
||||
}
|
||||
|
@ -272,5 +273,5 @@ func MilestoneIssuesAndPulls(ctx *context.Context) {
|
|||
ctx.Data["CanWriteIssues"] = ctx.Repo.CanWriteIssuesOrPulls(false)
|
||||
ctx.Data["CanWritePulls"] = ctx.Repo.CanWriteIssuesOrPulls(true)
|
||||
|
||||
ctx.HTML(200, tplMilestoneIssues)
|
||||
ctx.HTML(http.StatusOK, tplMilestoneIssues)
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ package repo
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
|
@ -101,7 +102,7 @@ func Projects(ctx *context.Context) {
|
|||
ctx.Data["IsProjectsPage"] = true
|
||||
ctx.Data["SortType"] = sortType
|
||||
|
||||
ctx.HTML(200, tplProjects)
|
||||
ctx.HTML(http.StatusOK, tplProjects)
|
||||
}
|
||||
|
||||
// NewProject render creating a project page
|
||||
|
@ -109,7 +110,7 @@ func NewProject(ctx *context.Context) {
|
|||
ctx.Data["Title"] = ctx.Tr("repo.projects.new")
|
||||
ctx.Data["ProjectTypes"] = models.GetProjectsConfig()
|
||||
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(models.UnitTypeProjects)
|
||||
ctx.HTML(200, tplProjectsNew)
|
||||
ctx.HTML(http.StatusOK, tplProjectsNew)
|
||||
}
|
||||
|
||||
// NewProjectPost creates a new project
|
||||
|
@ -120,7 +121,7 @@ func NewProjectPost(ctx *context.Context) {
|
|||
if ctx.HasError() {
|
||||
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(models.UnitTypeProjects)
|
||||
ctx.Data["ProjectTypes"] = models.GetProjectsConfig()
|
||||
ctx.HTML(200, tplProjectsNew)
|
||||
ctx.HTML(http.StatusOK, tplProjectsNew)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -186,7 +187,7 @@ func DeleteProject(ctx *context.Context) {
|
|||
ctx.Flash.Success(ctx.Tr("repo.projects.deletion_success"))
|
||||
}
|
||||
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"redirect": ctx.Repo.RepoLink + "/projects",
|
||||
})
|
||||
}
|
||||
|
@ -215,7 +216,7 @@ func EditProject(ctx *context.Context) {
|
|||
ctx.Data["title"] = p.Title
|
||||
ctx.Data["content"] = p.Description
|
||||
|
||||
ctx.HTML(200, tplProjectsNew)
|
||||
ctx.HTML(http.StatusOK, tplProjectsNew)
|
||||
}
|
||||
|
||||
// EditProjectPost response for editing a project
|
||||
|
@ -227,7 +228,7 @@ func EditProjectPost(ctx *context.Context) {
|
|||
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(models.UnitTypeProjects)
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, tplProjectsNew)
|
||||
ctx.HTML(http.StatusOK, tplProjectsNew)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -318,7 +319,7 @@ func ViewProject(ctx *context.Context) {
|
|||
ctx.Data["PageIsProjects"] = true
|
||||
ctx.Data["RequiresDraggable"] = true
|
||||
|
||||
ctx.HTML(200, tplProjectsView)
|
||||
ctx.HTML(http.StatusOK, tplProjectsView)
|
||||
}
|
||||
|
||||
// UpdateIssueProject change an issue's project
|
||||
|
@ -341,7 +342,7 @@ func UpdateIssueProject(ctx *context.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"ok": true,
|
||||
})
|
||||
}
|
||||
|
@ -349,14 +350,14 @@ func UpdateIssueProject(ctx *context.Context) {
|
|||
// DeleteProjectBoard allows for the deletion of a project board
|
||||
func DeleteProjectBoard(ctx *context.Context) {
|
||||
if ctx.User == nil {
|
||||
ctx.JSON(403, map[string]string{
|
||||
ctx.JSON(http.StatusForbidden, map[string]string{
|
||||
"message": "Only signed in users are allowed to perform this action.",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if !ctx.Repo.IsOwner() && !ctx.Repo.IsAdmin() && !ctx.Repo.CanAccess(models.AccessModeWrite, models.UnitTypeProjects) {
|
||||
ctx.JSON(403, map[string]string{
|
||||
ctx.JSON(http.StatusForbidden, map[string]string{
|
||||
"message": "Only authorized users are allowed to perform this action.",
|
||||
})
|
||||
return
|
||||
|
@ -378,14 +379,14 @@ func DeleteProjectBoard(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
if pb.ProjectID != ctx.ParamsInt64(":id") {
|
||||
ctx.JSON(422, map[string]string{
|
||||
ctx.JSON(http.StatusUnprocessableEntity, map[string]string{
|
||||
"message": fmt.Sprintf("ProjectBoard[%d] is not in Project[%d] as expected", pb.ID, project.ID),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if project.RepoID != ctx.Repo.Repository.ID {
|
||||
ctx.JSON(422, map[string]string{
|
||||
ctx.JSON(http.StatusUnprocessableEntity, map[string]string{
|
||||
"message": fmt.Sprintf("ProjectBoard[%d] is not in Repository[%d] as expected", pb.ID, ctx.Repo.Repository.ID),
|
||||
})
|
||||
return
|
||||
|
@ -396,7 +397,7 @@ func DeleteProjectBoard(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"ok": true,
|
||||
})
|
||||
}
|
||||
|
@ -405,7 +406,7 @@ func DeleteProjectBoard(ctx *context.Context) {
|
|||
func AddBoardToProjectPost(ctx *context.Context) {
|
||||
form := web.GetForm(ctx).(*auth.EditProjectBoardForm)
|
||||
if !ctx.Repo.IsOwner() && !ctx.Repo.IsAdmin() && !ctx.Repo.CanAccess(models.AccessModeWrite, models.UnitTypeProjects) {
|
||||
ctx.JSON(403, map[string]string{
|
||||
ctx.JSON(http.StatusForbidden, map[string]string{
|
||||
"message": "Only authorized users are allowed to perform this action.",
|
||||
})
|
||||
return
|
||||
|
@ -430,21 +431,21 @@ func AddBoardToProjectPost(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"ok": true,
|
||||
})
|
||||
}
|
||||
|
||||
func checkProjectBoardChangePermissions(ctx *context.Context) (*models.Project, *models.ProjectBoard) {
|
||||
if ctx.User == nil {
|
||||
ctx.JSON(403, map[string]string{
|
||||
ctx.JSON(http.StatusForbidden, map[string]string{
|
||||
"message": "Only signed in users are allowed to perform this action.",
|
||||
})
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
if !ctx.Repo.IsOwner() && !ctx.Repo.IsAdmin() && !ctx.Repo.CanAccess(models.AccessModeWrite, models.UnitTypeProjects) {
|
||||
ctx.JSON(403, map[string]string{
|
||||
ctx.JSON(http.StatusForbidden, map[string]string{
|
||||
"message": "Only authorized users are allowed to perform this action.",
|
||||
})
|
||||
return nil, nil
|
||||
|
@ -466,14 +467,14 @@ func checkProjectBoardChangePermissions(ctx *context.Context) (*models.Project,
|
|||
return nil, nil
|
||||
}
|
||||
if board.ProjectID != ctx.ParamsInt64(":id") {
|
||||
ctx.JSON(422, map[string]string{
|
||||
ctx.JSON(http.StatusUnprocessableEntity, map[string]string{
|
||||
"message": fmt.Sprintf("ProjectBoard[%d] is not in Project[%d] as expected", board.ID, project.ID),
|
||||
})
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
if project.RepoID != ctx.Repo.Repository.ID {
|
||||
ctx.JSON(422, map[string]string{
|
||||
ctx.JSON(http.StatusUnprocessableEntity, map[string]string{
|
||||
"message": fmt.Sprintf("ProjectBoard[%d] is not in Repository[%d] as expected", board.ID, ctx.Repo.Repository.ID),
|
||||
})
|
||||
return nil, nil
|
||||
|
@ -502,7 +503,7 @@ func EditProjectBoard(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"ok": true,
|
||||
})
|
||||
}
|
||||
|
@ -520,7 +521,7 @@ func SetDefaultProjectBoard(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"ok": true,
|
||||
})
|
||||
}
|
||||
|
@ -529,14 +530,14 @@ func SetDefaultProjectBoard(ctx *context.Context) {
|
|||
func MoveIssueAcrossBoards(ctx *context.Context) {
|
||||
|
||||
if ctx.User == nil {
|
||||
ctx.JSON(403, map[string]string{
|
||||
ctx.JSON(http.StatusForbidden, map[string]string{
|
||||
"message": "Only signed in users are allowed to perform this action.",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if !ctx.Repo.IsOwner() && !ctx.Repo.IsAdmin() && !ctx.Repo.CanAccess(models.AccessModeWrite, models.UnitTypeProjects) {
|
||||
ctx.JSON(403, map[string]string{
|
||||
ctx.JSON(http.StatusForbidden, map[string]string{
|
||||
"message": "Only authorized users are allowed to perform this action.",
|
||||
})
|
||||
return
|
||||
|
@ -598,7 +599,7 @@ func MoveIssueAcrossBoards(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"ok": true,
|
||||
})
|
||||
}
|
||||
|
@ -609,7 +610,7 @@ func CreateProject(ctx *context.Context) {
|
|||
ctx.Data["ProjectTypes"] = models.GetProjectsConfig()
|
||||
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(models.UnitTypeProjects)
|
||||
|
||||
ctx.HTML(200, tplGenericProjectsNew)
|
||||
ctx.HTML(http.StatusOK, tplGenericProjectsNew)
|
||||
}
|
||||
|
||||
// CreateProjectPost creates an individual and/or organization project
|
||||
|
@ -624,7 +625,7 @@ func CreateProjectPost(ctx *context.Context, form auth.UserCreateProjectForm) {
|
|||
|
||||
if ctx.HasError() {
|
||||
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(models.UnitTypeProjects)
|
||||
ctx.HTML(200, tplGenericProjectsNew)
|
||||
ctx.HTML(http.StatusOK, tplGenericProjectsNew)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -167,7 +167,7 @@ func Fork(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
ctx.HTML(200, tplFork)
|
||||
ctx.HTML(http.StatusOK, tplFork)
|
||||
}
|
||||
|
||||
// ForkPost response for forking a repository
|
||||
|
@ -188,7 +188,7 @@ func ForkPost(ctx *context.Context) {
|
|||
ctx.Data["ContextUser"] = ctxUser
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, tplFork)
|
||||
ctx.HTML(http.StatusOK, tplFork)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ func ForkPost(ctx *context.Context) {
|
|||
ctx.ServerError("IsOwnedBy", err)
|
||||
return
|
||||
} else if !isOwner {
|
||||
ctx.Error(403)
|
||||
ctx.Error(http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -570,7 +570,7 @@ func ViewPullCommits(ctx *context.Context) {
|
|||
ctx.Data["CommitCount"] = commits.Len()
|
||||
|
||||
getBranchData(ctx, issue)
|
||||
ctx.HTML(200, tplPullCommits)
|
||||
ctx.HTML(http.StatusOK, tplPullCommits)
|
||||
}
|
||||
|
||||
// ViewPullFiles render pull request changed files list page
|
||||
|
@ -692,7 +692,7 @@ func ViewPullFiles(ctx *context.Context) {
|
|||
getBranchData(ctx, issue)
|
||||
ctx.Data["IsIssuePoster"] = ctx.IsSigned && issue.IsPoster(ctx.User.ID)
|
||||
ctx.Data["HasIssuesOrPullsWritePermission"] = ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)
|
||||
ctx.HTML(200, tplPullFiles)
|
||||
ctx.HTML(http.StatusOK, tplPullFiles)
|
||||
}
|
||||
|
||||
// UpdatePullRequest merge PR's baseBranch into headBranch
|
||||
|
@ -1015,7 +1015,7 @@ func CompareAndPullRequestPost(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
ctx.HTML(200, tplCompareDiff)
|
||||
ctx.HTML(http.StatusOK, tplCompareDiff)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1054,7 +1054,7 @@ func CompareAndPullRequestPost(ctx *context.Context) {
|
|||
|
||||
if err := pull_service.NewPullRequest(repo, pullIssue, labelIDs, attachments, pullRequest, assigneeIDs); err != nil {
|
||||
if models.IsErrUserDoesNotHaveAccessToRepo(err) {
|
||||
ctx.Error(400, "UserDoesNotHaveAccessToRepo", err.Error())
|
||||
ctx.Error(http.StatusBadRequest, "UserDoesNotHaveAccessToRepo", err.Error())
|
||||
return
|
||||
} else if git.IsErrPushRejected(err) {
|
||||
pushrejErr := err.(*git.ErrPushRejected)
|
||||
|
@ -1090,7 +1090,7 @@ func TriggerTask(ctx *context.Context) {
|
|||
branch := ctx.Query("branch")
|
||||
secret := ctx.Query("secret")
|
||||
if len(branch) == 0 || len(secret) == 0 || pusherID <= 0 {
|
||||
ctx.Error(404)
|
||||
ctx.Error(http.StatusNotFound)
|
||||
log.Trace("TriggerTask: branch or secret is empty, or pusher ID is not valid")
|
||||
return
|
||||
}
|
||||
|
@ -1101,7 +1101,7 @@ func TriggerTask(ctx *context.Context) {
|
|||
got := []byte(base.EncodeMD5(owner.Salt))
|
||||
want := []byte(secret)
|
||||
if subtle.ConstantTimeCompare(got, want) != 1 {
|
||||
ctx.Error(404)
|
||||
ctx.Error(http.StatusNotFound)
|
||||
log.Trace("TriggerTask [%s/%s]: invalid secret", owner.Name, repo.Name)
|
||||
return
|
||||
}
|
||||
|
@ -1109,7 +1109,7 @@ func TriggerTask(ctx *context.Context) {
|
|||
pusher, err := models.GetUserByID(pusherID)
|
||||
if err != nil {
|
||||
if models.IsErrUserNotExist(err) {
|
||||
ctx.Error(404)
|
||||
ctx.Error(http.StatusNotFound)
|
||||
} else {
|
||||
ctx.ServerError("GetUserByID", err)
|
||||
}
|
||||
|
@ -1179,7 +1179,7 @@ func CleanUpPullRequest(ctx *context.Context) {
|
|||
defer gitBaseRepo.Close()
|
||||
|
||||
defer func() {
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"redirect": pr.BaseRepo.Link() + "/pulls/" + fmt.Sprint(issue.Index),
|
||||
})
|
||||
}()
|
||||
|
|
|
@ -6,6 +6,7 @@ package repo
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/base"
|
||||
|
@ -41,7 +42,7 @@ func RenderNewCodeCommentForm(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
ctx.Data["AfterCommitID"] = pullHeadCommitID
|
||||
ctx.HTML(200, tplNewComment)
|
||||
ctx.HTML(http.StatusOK, tplNewComment)
|
||||
}
|
||||
|
||||
// CreateCodeComment will create a code comment including an pending review if required
|
||||
|
@ -120,12 +121,12 @@ func UpdateResolveConversation(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
if !permResult {
|
||||
ctx.Error(403)
|
||||
ctx.Error(http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
if !comment.Issue.IsPull {
|
||||
ctx.Error(400)
|
||||
ctx.Error(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -136,7 +137,7 @@ func UpdateResolveConversation(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
} else {
|
||||
ctx.Error(400)
|
||||
ctx.Error(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -144,7 +145,7 @@ func UpdateResolveConversation(ctx *context.Context) {
|
|||
renderConversation(ctx, comment)
|
||||
return
|
||||
}
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"ok": true,
|
||||
})
|
||||
}
|
||||
|
@ -169,7 +170,7 @@ func renderConversation(ctx *context.Context, comment *models.Comment) {
|
|||
return
|
||||
}
|
||||
ctx.Data["AfterCommitID"] = pullHeadCommitID
|
||||
ctx.HTML(200, tplConversation)
|
||||
ctx.HTML(http.StatusOK, tplConversation)
|
||||
}
|
||||
|
||||
// SubmitReview creates a review out of the existing pending review or creates a new one if no pending review exist
|
||||
|
|
|
@ -7,6 +7,7 @@ package repo
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
|
@ -141,7 +142,7 @@ func releasesOrTags(ctx *context.Context, isTagList bool) {
|
|||
pager.SetDefaultParams(ctx)
|
||||
ctx.Data["Page"] = pager
|
||||
|
||||
ctx.HTML(200, tplReleases)
|
||||
ctx.HTML(http.StatusOK, tplReleases)
|
||||
}
|
||||
|
||||
// SingleRelease renders a single release's page
|
||||
|
@ -184,7 +185,7 @@ func SingleRelease(ctx *context.Context) {
|
|||
release.Note = markdown.RenderString(release.Note, ctx.Repo.RepoLink, ctx.Repo.Repository.ComposeMetas())
|
||||
|
||||
ctx.Data["Releases"] = []*models.Release{release}
|
||||
ctx.HTML(200, tplReleases)
|
||||
ctx.HTML(http.StatusOK, tplReleases)
|
||||
}
|
||||
|
||||
// LatestRelease redirects to the latest release
|
||||
|
@ -237,7 +238,7 @@ func NewRelease(ctx *context.Context) {
|
|||
}
|
||||
ctx.Data["IsAttachmentEnabled"] = setting.Attachment.Enabled
|
||||
upload.AddUploadContext(ctx, "release")
|
||||
ctx.HTML(200, tplReleaseNew)
|
||||
ctx.HTML(http.StatusOK, tplReleaseNew)
|
||||
}
|
||||
|
||||
// NewReleasePost response for creating a release
|
||||
|
@ -249,7 +250,7 @@ func NewReleasePost(ctx *context.Context) {
|
|||
ctx.Data["RequireTribute"] = true
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, tplReleaseNew)
|
||||
ctx.HTML(http.StatusOK, tplReleaseNew)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -378,7 +379,7 @@ func EditRelease(ctx *context.Context) {
|
|||
}
|
||||
ctx.Data["attachments"] = rel.Attachments
|
||||
|
||||
ctx.HTML(200, tplReleaseNew)
|
||||
ctx.HTML(http.StatusOK, tplReleaseNew)
|
||||
}
|
||||
|
||||
// EditReleasePost response for edit release
|
||||
|
@ -411,7 +412,7 @@ func EditReleasePost(ctx *context.Context) {
|
|||
ctx.Data["prerelease"] = rel.IsPrerelease
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, tplReleaseNew)
|
||||
ctx.HTML(http.StatusOK, tplReleaseNew)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -464,13 +465,13 @@ func deleteReleaseOrTag(ctx *context.Context, isDelTag bool) {
|
|||
}
|
||||
|
||||
if isDelTag {
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"redirect": ctx.Repo.RepoLink + "/tags",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"redirect": ctx.Repo.RepoLink + "/releases",
|
||||
})
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ package repo
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -85,7 +86,7 @@ func checkContextUser(ctx *context.Context, uid int64) *models.User {
|
|||
|
||||
// Check ownership of organization.
|
||||
if !org.IsOrganization() {
|
||||
ctx.Error(403)
|
||||
ctx.Error(http.StatusForbidden)
|
||||
return nil
|
||||
}
|
||||
if !ctx.User.IsAdmin {
|
||||
|
@ -94,7 +95,7 @@ func checkContextUser(ctx *context.Context, uid int64) *models.User {
|
|||
ctx.ServerError("CanCreateOrgRepo", err)
|
||||
return nil
|
||||
} else if !canCreate {
|
||||
ctx.Error(403)
|
||||
ctx.Error(http.StatusForbidden)
|
||||
return nil
|
||||
}
|
||||
} else {
|
||||
|
@ -149,7 +150,7 @@ func Create(ctx *context.Context) {
|
|||
ctx.Data["CanCreateRepo"] = ctx.User.CanCreateRepo()
|
||||
ctx.Data["MaxCreationLimit"] = ctx.User.MaxCreationLimit()
|
||||
|
||||
ctx.HTML(200, tplCreate)
|
||||
ctx.HTML(http.StatusOK, tplCreate)
|
||||
}
|
||||
|
||||
func handleCreateError(ctx *context.Context, owner *models.User, err error, name string, tpl base.TplName, form interface{}) {
|
||||
|
@ -199,7 +200,7 @@ func CreatePost(ctx *context.Context) {
|
|||
ctx.Data["ContextUser"] = ctxUser
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, tplCreate)
|
||||
ctx.HTML(http.StatusOK, tplCreate)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -281,7 +282,7 @@ func Action(ctx *context.Context) {
|
|||
err = acceptOrRejectRepoTransfer(ctx, false)
|
||||
case "desc": // FIXME: this is not used
|
||||
if !ctx.Repo.IsOwner() {
|
||||
ctx.Error(404)
|
||||
ctx.Error(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -339,7 +340,7 @@ func RedirectDownload(ctx *context.Context) {
|
|||
releases, err := models.GetReleasesByRepoIDAndNames(models.DefaultDBContext(), curRepo.ID, tagNames)
|
||||
if err != nil {
|
||||
if models.IsErrAttachmentNotExist(err) {
|
||||
ctx.Error(404)
|
||||
ctx.Error(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
ctx.ServerError("RedirectDownload", err)
|
||||
|
@ -349,7 +350,7 @@ func RedirectDownload(ctx *context.Context) {
|
|||
release := releases[0]
|
||||
att, err := models.GetAttachmentByReleaseIDFileName(release.ID, fileName)
|
||||
if err != nil {
|
||||
ctx.Error(404)
|
||||
ctx.Error(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
if att != nil {
|
||||
|
@ -357,7 +358,7 @@ func RedirectDownload(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
}
|
||||
ctx.Error(404)
|
||||
ctx.Error(http.StatusNotFound)
|
||||
}
|
||||
|
||||
// Download an archive of a repository
|
||||
|
@ -366,7 +367,7 @@ func Download(ctx *context.Context) {
|
|||
aReq := archiver_service.DeriveRequestFrom(ctx, uri)
|
||||
|
||||
if aReq == nil {
|
||||
ctx.Error(404)
|
||||
ctx.Error(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -380,7 +381,7 @@ func Download(ctx *context.Context) {
|
|||
if complete {
|
||||
ctx.ServeFile(aReq.GetArchivePath(), downloadName)
|
||||
} else {
|
||||
ctx.Error(404)
|
||||
ctx.Error(http.StatusNotFound)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -392,7 +393,7 @@ func InitiateDownload(ctx *context.Context) {
|
|||
aReq := archiver_service.DeriveRequestFrom(ctx, uri)
|
||||
|
||||
if aReq == nil {
|
||||
ctx.Error(404)
|
||||
ctx.Error(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -402,7 +403,7 @@ func InitiateDownload(ctx *context.Context) {
|
|||
complete, _ = aReq.TimedWaitForCompletion(ctx, 2*time.Second)
|
||||
}
|
||||
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"complete": complete,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
package repo
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
|
@ -51,5 +52,5 @@ func Search(ctx *context.Context) {
|
|||
pager.AddParam(ctx, "l", "Language")
|
||||
ctx.Data["Page"] = pager
|
||||
|
||||
ctx.HTML(200, tplSearch)
|
||||
ctx.HTML(http.StatusOK, tplSearch)
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -51,7 +52,7 @@ func Settings(ctx *context.Context) {
|
|||
ctx.Data["SigningKeyAvailable"] = len(signing) > 0
|
||||
ctx.Data["SigningSettings"] = setting.Repository.Signing
|
||||
|
||||
ctx.HTML(200, tplSettingsOptions)
|
||||
ctx.HTML(http.StatusOK, tplSettingsOptions)
|
||||
}
|
||||
|
||||
// SettingsPost response for changes of a repository
|
||||
|
@ -65,7 +66,7 @@ func SettingsPost(ctx *context.Context) {
|
|||
switch ctx.Query("action") {
|
||||
case "update":
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, tplSettingsOptions)
|
||||
ctx.HTML(http.StatusOK, tplSettingsOptions)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -366,7 +367,7 @@ func SettingsPost(ctx *context.Context) {
|
|||
|
||||
case "admin":
|
||||
if !ctx.User.IsAdmin {
|
||||
ctx.Error(403)
|
||||
ctx.Error(http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -386,7 +387,7 @@ func SettingsPost(ctx *context.Context) {
|
|||
|
||||
case "convert":
|
||||
if !ctx.Repo.IsOwner() {
|
||||
ctx.Error(404)
|
||||
ctx.Error(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
if repo.Name != form.RepoName {
|
||||
|
@ -395,7 +396,7 @@ func SettingsPost(ctx *context.Context) {
|
|||
}
|
||||
|
||||
if !repo.IsMirror {
|
||||
ctx.Error(404)
|
||||
ctx.Error(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
repo.IsMirror = false
|
||||
|
@ -413,7 +414,7 @@ func SettingsPost(ctx *context.Context) {
|
|||
|
||||
case "convert_fork":
|
||||
if !ctx.Repo.IsOwner() {
|
||||
ctx.Error(404)
|
||||
ctx.Error(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
if err := repo.GetOwner(); err != nil {
|
||||
|
@ -426,7 +427,7 @@ func SettingsPost(ctx *context.Context) {
|
|||
}
|
||||
|
||||
if !repo.IsFork {
|
||||
ctx.Error(404)
|
||||
ctx.Error(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -450,7 +451,7 @@ func SettingsPost(ctx *context.Context) {
|
|||
|
||||
case "transfer":
|
||||
if !ctx.Repo.IsOwner() {
|
||||
ctx.Error(404)
|
||||
ctx.Error(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
if repo.Name != form.RepoName {
|
||||
|
@ -500,7 +501,7 @@ func SettingsPost(ctx *context.Context) {
|
|||
|
||||
case "cancel_transfer":
|
||||
if !ctx.Repo.IsOwner() {
|
||||
ctx.Error(404)
|
||||
ctx.Error(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -532,7 +533,7 @@ func SettingsPost(ctx *context.Context) {
|
|||
|
||||
case "delete":
|
||||
if !ctx.Repo.IsOwner() {
|
||||
ctx.Error(404)
|
||||
ctx.Error(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
if repo.Name != form.RepoName {
|
||||
|
@ -551,7 +552,7 @@ func SettingsPost(ctx *context.Context) {
|
|||
|
||||
case "delete-wiki":
|
||||
if !ctx.Repo.IsOwner() {
|
||||
ctx.Error(404)
|
||||
ctx.Error(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
if repo.Name != form.RepoName {
|
||||
|
@ -570,7 +571,7 @@ func SettingsPost(ctx *context.Context) {
|
|||
|
||||
case "archive":
|
||||
if !ctx.Repo.IsOwner() {
|
||||
ctx.Error(403)
|
||||
ctx.Error(http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -593,7 +594,7 @@ func SettingsPost(ctx *context.Context) {
|
|||
ctx.Redirect(ctx.Repo.RepoLink + "/settings")
|
||||
case "unarchive":
|
||||
if !ctx.Repo.IsOwner() {
|
||||
ctx.Error(403)
|
||||
ctx.Error(http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -638,7 +639,7 @@ func Collaboration(ctx *context.Context) {
|
|||
ctx.Data["Org"] = ctx.Repo.Repository.Owner
|
||||
ctx.Data["Units"] = models.Units
|
||||
|
||||
ctx.HTML(200, tplCollaboration)
|
||||
ctx.HTML(http.StatusOK, tplCollaboration)
|
||||
}
|
||||
|
||||
// CollaborationPost response for actions for a collaboration of a repository
|
||||
|
@ -709,7 +710,7 @@ func DeleteCollaboration(ctx *context.Context) {
|
|||
ctx.Flash.Success(ctx.Tr("repo.settings.remove_collaborator_success"))
|
||||
}
|
||||
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"redirect": ctx.Repo.RepoLink + "/settings/collaboration",
|
||||
})
|
||||
}
|
||||
|
@ -780,7 +781,7 @@ func DeleteTeam(ctx *context.Context) {
|
|||
}
|
||||
|
||||
ctx.Flash.Success(ctx.Tr("repo.settings.remove_team_success"))
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"redirect": ctx.Repo.RepoLink + "/settings/collaboration",
|
||||
})
|
||||
}
|
||||
|
@ -822,7 +823,7 @@ func GitHooks(ctx *context.Context) {
|
|||
}
|
||||
ctx.Data["Hooks"] = hooks
|
||||
|
||||
ctx.HTML(200, tplGithooks)
|
||||
ctx.HTML(http.StatusOK, tplGithooks)
|
||||
}
|
||||
|
||||
// GitHooksEdit render for editing a hook of repository page
|
||||
|
@ -841,7 +842,7 @@ func GitHooksEdit(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
ctx.Data["Hook"] = hook
|
||||
ctx.HTML(200, tplGithookEdit)
|
||||
ctx.HTML(http.StatusOK, tplGithookEdit)
|
||||
}
|
||||
|
||||
// GitHooksEditPost response for editing a git hook of a repository
|
||||
|
@ -877,7 +878,7 @@ func DeployKeys(ctx *context.Context) {
|
|||
}
|
||||
ctx.Data["Deploykeys"] = keys
|
||||
|
||||
ctx.HTML(200, tplDeployKeys)
|
||||
ctx.HTML(http.StatusOK, tplDeployKeys)
|
||||
}
|
||||
|
||||
// DeployKeysPost response for adding a deploy key of a repository
|
||||
|
@ -894,7 +895,7 @@ func DeployKeysPost(ctx *context.Context) {
|
|||
ctx.Data["Deploykeys"] = keys
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, tplDeployKeys)
|
||||
ctx.HTML(http.StatusOK, tplDeployKeys)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -948,7 +949,7 @@ func DeleteDeployKey(ctx *context.Context) {
|
|||
ctx.Flash.Success(ctx.Tr("repo.settings.deploy_key_deletion_success"))
|
||||
}
|
||||
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"redirect": ctx.Repo.RepoLink + "/settings/keys",
|
||||
})
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ package repo
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -49,7 +50,7 @@ func ProtectedBranch(ctx *context.Context) {
|
|||
|
||||
ctx.Data["LeftBranches"] = leftBranches
|
||||
|
||||
ctx.HTML(200, tplBranches)
|
||||
ctx.HTML(http.StatusOK, tplBranches)
|
||||
}
|
||||
|
||||
// ProtectedBranchPost response for protect for a branch of a repository
|
||||
|
@ -62,7 +63,7 @@ func ProtectedBranchPost(ctx *context.Context) {
|
|||
switch ctx.Query("action") {
|
||||
case "default_branch":
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, tplBranches)
|
||||
ctx.HTML(http.StatusOK, tplBranches)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -165,7 +166,7 @@ func SettingsProtectedBranch(c *context.Context) {
|
|||
}
|
||||
|
||||
c.Data["Branch"] = protectBranch
|
||||
c.HTML(200, tplProtectedBranch)
|
||||
c.HTML(http.StatusOK, tplProtectedBranch)
|
||||
}
|
||||
|
||||
// SettingsProtectedBranchPost updates the protected branch settings
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
package repo
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
|
@ -15,7 +16,7 @@ import (
|
|||
// TopicsPost response for creating repository
|
||||
func TopicsPost(ctx *context.Context) {
|
||||
if ctx.User == nil {
|
||||
ctx.JSON(403, map[string]interface{}{
|
||||
ctx.JSON(http.StatusForbidden, map[string]interface{}{
|
||||
"message": "Only owners could change the topics.",
|
||||
})
|
||||
return
|
||||
|
@ -30,7 +31,7 @@ func TopicsPost(ctx *context.Context) {
|
|||
validTopics, invalidTopics := models.SanitizeAndValidateTopics(topics)
|
||||
|
||||
if len(validTopics) > 25 {
|
||||
ctx.JSON(422, map[string]interface{}{
|
||||
ctx.JSON(http.StatusUnprocessableEntity, map[string]interface{}{
|
||||
"invalidTopics": nil,
|
||||
"message": ctx.Tr("repo.topic.count_prompt"),
|
||||
})
|
||||
|
@ -38,7 +39,7 @@ func TopicsPost(ctx *context.Context) {
|
|||
}
|
||||
|
||||
if len(invalidTopics) > 0 {
|
||||
ctx.JSON(422, map[string]interface{}{
|
||||
ctx.JSON(http.StatusUnprocessableEntity, map[string]interface{}{
|
||||
"invalidTopics": invalidTopics,
|
||||
"message": ctx.Tr("repo.topic.format_prompt"),
|
||||
})
|
||||
|
@ -48,13 +49,13 @@ func TopicsPost(ctx *context.Context) {
|
|||
err := models.SaveTopics(ctx.Repo.Repository.ID, validTopics...)
|
||||
if err != nil {
|
||||
log.Error("SaveTopics failed: %v", err)
|
||||
ctx.JSON(500, map[string]interface{}{
|
||||
ctx.JSON(http.StatusInternalServerError, map[string]interface{}{
|
||||
"message": "Save topics failed.",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"status": "ok",
|
||||
})
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import (
|
|||
gotemplate "html/template"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path"
|
||||
"strconv"
|
||||
|
@ -582,7 +583,7 @@ func Home(ctx *context.Context) {
|
|||
ctx.Data["Repo"] = ctx.Repo
|
||||
ctx.Data["MigrateTask"] = task
|
||||
ctx.Data["CloneAddr"] = safeURL(cfg.CloneAddr)
|
||||
ctx.HTML(200, tplMigrating)
|
||||
ctx.HTML(http.StatusOK, tplMigrating)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -641,7 +642,7 @@ func renderCode(ctx *context.Context) {
|
|||
ctx.Data["PageIsViewCode"] = true
|
||||
|
||||
if ctx.Repo.Repository.IsEmpty {
|
||||
ctx.HTML(200, tplRepoEMPTY)
|
||||
ctx.HTML(http.StatusOK, tplRepoEMPTY)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -704,7 +705,7 @@ func renderCode(ctx *context.Context) {
|
|||
ctx.Data["TreeLink"] = treeLink
|
||||
ctx.Data["TreeNames"] = treeNames
|
||||
ctx.Data["BranchLink"] = branchLink
|
||||
ctx.HTML(200, tplRepoHome)
|
||||
ctx.HTML(http.StatusOK, tplRepoHome)
|
||||
}
|
||||
|
||||
// RenderUserCards render a page show users according the input templaet
|
||||
|
@ -726,7 +727,7 @@ func RenderUserCards(ctx *context.Context, total int, getter func(opts models.Li
|
|||
}
|
||||
ctx.Data["Cards"] = items
|
||||
|
||||
ctx.HTML(200, tpl)
|
||||
ctx.HTML(http.StatusOK, tpl)
|
||||
}
|
||||
|
||||
// Watchers render repository's watch users
|
||||
|
@ -765,5 +766,5 @@ func Forks(ctx *context.Context) {
|
|||
}
|
||||
ctx.Data["Forks"] = forks
|
||||
|
||||
ctx.HTML(200, tplForks)
|
||||
ctx.HTML(http.StatusOK, tplForks)
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ package repo
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
|
@ -47,7 +48,7 @@ func Webhooks(ctx *context.Context) {
|
|||
}
|
||||
ctx.Data["Webhooks"] = ws
|
||||
|
||||
ctx.HTML(200, tplHooks)
|
||||
ctx.HTML(http.StatusOK, tplHooks)
|
||||
}
|
||||
|
||||
type orgRepoCtx struct {
|
||||
|
@ -148,7 +149,7 @@ func WebhooksNew(ctx *context.Context) {
|
|||
}
|
||||
ctx.Data["BaseLink"] = orCtx.LinkNew
|
||||
|
||||
ctx.HTML(200, orCtx.NewTemplate)
|
||||
ctx.HTML(http.StatusOK, orCtx.NewTemplate)
|
||||
}
|
||||
|
||||
// ParseHookEvent convert web form content to models.HookEvent
|
||||
|
@ -198,7 +199,7 @@ func GiteaHooksNewPost(ctx *context.Context) {
|
|||
ctx.Data["BaseLink"] = orCtx.LinkNew
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, orCtx.NewTemplate)
|
||||
ctx.HTML(http.StatusOK, orCtx.NewTemplate)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -253,7 +254,7 @@ func newGogsWebhookPost(ctx *context.Context, form auth.NewGogshookForm, kind mo
|
|||
ctx.Data["BaseLink"] = orCtx.LinkNew
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, orCtx.NewTemplate)
|
||||
ctx.HTML(http.StatusOK, orCtx.NewTemplate)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -301,7 +302,7 @@ func DiscordHooksNewPost(ctx *context.Context) {
|
|||
}
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, orCtx.NewTemplate)
|
||||
ctx.HTML(http.StatusOK, orCtx.NewTemplate)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -354,7 +355,7 @@ func DingtalkHooksNewPost(ctx *context.Context) {
|
|||
}
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, orCtx.NewTemplate)
|
||||
ctx.HTML(http.StatusOK, orCtx.NewTemplate)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -397,7 +398,7 @@ func TelegramHooksNewPost(ctx *context.Context) {
|
|||
}
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, orCtx.NewTemplate)
|
||||
ctx.HTML(http.StatusOK, orCtx.NewTemplate)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -450,7 +451,7 @@ func MatrixHooksNewPost(ctx *context.Context) {
|
|||
}
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, orCtx.NewTemplate)
|
||||
ctx.HTML(http.StatusOK, orCtx.NewTemplate)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -506,7 +507,7 @@ func MSTeamsHooksNewPost(ctx *context.Context) {
|
|||
}
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, orCtx.NewTemplate)
|
||||
ctx.HTML(http.StatusOK, orCtx.NewTemplate)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -549,7 +550,7 @@ func SlackHooksNewPost(ctx *context.Context) {
|
|||
}
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, orCtx.NewTemplate)
|
||||
ctx.HTML(http.StatusOK, orCtx.NewTemplate)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -610,7 +611,7 @@ func FeishuHooksNewPost(ctx *context.Context) {
|
|||
}
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, orCtx.NewTemplate)
|
||||
ctx.HTML(http.StatusOK, orCtx.NewTemplate)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -695,7 +696,7 @@ func WebHooksEdit(ctx *context.Context) {
|
|||
}
|
||||
ctx.Data["Webhook"] = w
|
||||
|
||||
ctx.HTML(200, orCtx.NewTemplate)
|
||||
ctx.HTML(http.StatusOK, orCtx.NewTemplate)
|
||||
}
|
||||
|
||||
// WebHooksEditPost response for editing web hook
|
||||
|
@ -712,7 +713,7 @@ func WebHooksEditPost(ctx *context.Context) {
|
|||
ctx.Data["Webhook"] = w
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, orCtx.NewTemplate)
|
||||
ctx.HTML(http.StatusOK, orCtx.NewTemplate)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -753,7 +754,7 @@ func GogsHooksEditPost(ctx *context.Context) {
|
|||
ctx.Data["Webhook"] = w
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, orCtx.NewTemplate)
|
||||
ctx.HTML(http.StatusOK, orCtx.NewTemplate)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -793,7 +794,7 @@ func SlackHooksEditPost(ctx *context.Context) {
|
|||
ctx.Data["Webhook"] = w
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, orCtx.NewTemplate)
|
||||
ctx.HTML(http.StatusOK, orCtx.NewTemplate)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -845,7 +846,7 @@ func DiscordHooksEditPost(ctx *context.Context) {
|
|||
ctx.Data["Webhook"] = w
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, orCtx.NewTemplate)
|
||||
ctx.HTML(http.StatusOK, orCtx.NewTemplate)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -889,7 +890,7 @@ func DingtalkHooksEditPost(ctx *context.Context) {
|
|||
ctx.Data["Webhook"] = w
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, orCtx.NewTemplate)
|
||||
ctx.HTML(http.StatusOK, orCtx.NewTemplate)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -922,7 +923,7 @@ func TelegramHooksEditPost(ctx *context.Context) {
|
|||
ctx.Data["Webhook"] = w
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, orCtx.NewTemplate)
|
||||
ctx.HTML(http.StatusOK, orCtx.NewTemplate)
|
||||
return
|
||||
}
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
|
@ -964,7 +965,7 @@ func MatrixHooksEditPost(ctx *context.Context) {
|
|||
ctx.Data["Webhook"] = w
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, orCtx.NewTemplate)
|
||||
ctx.HTML(http.StatusOK, orCtx.NewTemplate)
|
||||
return
|
||||
}
|
||||
json := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
|
@ -1009,7 +1010,7 @@ func MSTeamsHooksEditPost(ctx *context.Context) {
|
|||
ctx.Data["Webhook"] = w
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, orCtx.NewTemplate)
|
||||
ctx.HTML(http.StatusOK, orCtx.NewTemplate)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1042,7 +1043,7 @@ func FeishuHooksEditPost(ctx *context.Context) {
|
|||
ctx.Data["Webhook"] = w
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, orCtx.NewTemplate)
|
||||
ctx.HTML(http.StatusOK, orCtx.NewTemplate)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1124,7 +1125,7 @@ func DeleteWebhook(ctx *context.Context) {
|
|||
ctx.Flash.Success(ctx.Tr("repo.settings.webhook_deletion_success"))
|
||||
}
|
||||
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"redirect": ctx.Repo.RepoLink + "/settings/hooks",
|
||||
})
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ package repo
|
|||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
@ -349,7 +350,7 @@ func Wiki(ctx *context.Context) {
|
|||
|
||||
if !ctx.Repo.Repository.HasWiki() {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.wiki")
|
||||
ctx.HTML(200, tplWikiStart)
|
||||
ctx.HTML(http.StatusOK, tplWikiStart)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -367,7 +368,7 @@ func Wiki(ctx *context.Context) {
|
|||
}()
|
||||
if entry == nil {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.wiki")
|
||||
ctx.HTML(200, tplWikiStart)
|
||||
ctx.HTML(http.StatusOK, tplWikiStart)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -384,7 +385,7 @@ func Wiki(ctx *context.Context) {
|
|||
}
|
||||
ctx.Data["Author"] = lastCommit.Author
|
||||
|
||||
ctx.HTML(200, tplWikiView)
|
||||
ctx.HTML(http.StatusOK, tplWikiView)
|
||||
}
|
||||
|
||||
// WikiRevision renders file revision list of wiki page
|
||||
|
@ -394,7 +395,7 @@ func WikiRevision(ctx *context.Context) {
|
|||
|
||||
if !ctx.Repo.Repository.HasWiki() {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.wiki")
|
||||
ctx.HTML(200, tplWikiStart)
|
||||
ctx.HTML(http.StatusOK, tplWikiStart)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -412,7 +413,7 @@ func WikiRevision(ctx *context.Context) {
|
|||
}()
|
||||
if entry == nil {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.wiki")
|
||||
ctx.HTML(200, tplWikiStart)
|
||||
ctx.HTML(http.StatusOK, tplWikiStart)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -425,7 +426,7 @@ func WikiRevision(ctx *context.Context) {
|
|||
}
|
||||
ctx.Data["Author"] = lastCommit.Author
|
||||
|
||||
ctx.HTML(200, tplWikiRevision)
|
||||
ctx.HTML(http.StatusOK, tplWikiRevision)
|
||||
}
|
||||
|
||||
// WikiPages render wiki pages list page
|
||||
|
@ -495,7 +496,7 @@ func WikiPages(ctx *context.Context) {
|
|||
wikiRepo.Close()
|
||||
}
|
||||
}()
|
||||
ctx.HTML(200, tplWikiPages)
|
||||
ctx.HTML(http.StatusOK, tplWikiPages)
|
||||
}
|
||||
|
||||
// WikiRaw outputs raw blob requested by user (image for example)
|
||||
|
@ -553,7 +554,7 @@ func NewWiki(ctx *context.Context) {
|
|||
ctx.Data["title"] = "Home"
|
||||
}
|
||||
|
||||
ctx.HTML(200, tplWikiNew)
|
||||
ctx.HTML(http.StatusOK, tplWikiNew)
|
||||
}
|
||||
|
||||
// NewWikiPost response for wiki create request
|
||||
|
@ -564,7 +565,7 @@ func NewWikiPost(ctx *context.Context) {
|
|||
ctx.Data["RequireSimpleMDE"] = true
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, tplWikiNew)
|
||||
ctx.HTML(http.StatusOK, tplWikiNew)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -611,7 +612,7 @@ func EditWiki(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
ctx.HTML(200, tplWikiNew)
|
||||
ctx.HTML(http.StatusOK, tplWikiNew)
|
||||
}
|
||||
|
||||
// EditWikiPost response for wiki modify request
|
||||
|
@ -622,7 +623,7 @@ func EditWikiPost(ctx *context.Context) {
|
|||
ctx.Data["RequireSimpleMDE"] = true
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, tplWikiNew)
|
||||
ctx.HTML(http.StatusOK, tplWikiNew)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -653,7 +654,7 @@ func DeleteWikiPagePost(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
ctx.JSON(200, map[string]interface{}{
|
||||
ctx.JSON(http.StatusOK, map[string]interface{}{
|
||||
"redirect": ctx.Repo.RepoLink + "/wiki/",
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue