aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorJakobDev <jakobdev@gmx.de>2023-08-31 17:36:25 +0200
committerGitHub <noreply@github.com>2023-08-31 15:36:25 +0000
commit3cae50e841bf1551d82fe9ae3fe5c88627029c24 (patch)
treed3f0652fca1ff1174856fc5c232ec0ec2005a082 /routers
parentd5703d4a1bab58234c9e8e0e0e78c0cd26a90dce (diff)
downloadgitea-3cae50e841bf1551d82fe9ae3fe5c88627029c24.tar.gz
gitea-3cae50e841bf1551d82fe9ae3fe5c88627029c24.zip
Redirect from `{repo}/issues/new` to `{repo}/issues/new/choose` when blank issues are disabled (#26813)
You can currently visit `{repo}/issues/new` and create a blank issue, even if it's disabled. This PR fixes this, Fixes https://codeberg.org/forgejo/forgejo/issues/1356 Co-authored-by: Giteabot <teabot@gitea.io>
Diffstat (limited to 'routers')
-rw-r--r--routers/web/repo/issue.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go
index b8b5a2dff2..f5e8f80ddf 100644
--- a/routers/web/repo/issue.go
+++ b/routers/web/repo/issue.go
@@ -902,9 +902,17 @@ func setTemplateIfExists(ctx *context.Context, ctxDataKey string, possibleFiles
// NewIssue render creating issue page
func NewIssue(ctx *context.Context) {
+ issueConfig, _ := issue_service.GetTemplateConfigFromDefaultBranch(ctx.Repo.Repository, ctx.Repo.GitRepo)
+ hasTemplates := issue_service.HasTemplatesOrContactLinks(ctx.Repo.Repository, ctx.Repo.GitRepo)
+ if !issueConfig.BlankIssuesEnabled && hasTemplates {
+ // The "issues/new" and "issues/new/choose" share the same query parameters "project" and "milestone", if blank issues are disabled, just redirect to the "issues/choose" page with these parameters.
+ ctx.Redirect(fmt.Sprintf("%s/issues/new/choose?%s", ctx.Repo.Repository.Link(), ctx.Req.URL.RawQuery), http.StatusSeeOther)
+ return
+ }
+
ctx.Data["Title"] = ctx.Tr("repo.issues.new")
ctx.Data["PageIsIssueList"] = true
- ctx.Data["NewIssueChooseTemplate"] = issue_service.HasTemplatesOrContactLinks(ctx.Repo.Repository, ctx.Repo.GitRepo)
+ ctx.Data["NewIssueChooseTemplate"] = hasTemplates
ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes
title := ctx.FormString("title")
ctx.Data["TitleQuery"] = title