diff --git a/modules/auth/repo_form.go b/modules/auth/repo_form.go index ab724e923..9ea5da879 100755 --- a/modules/auth/repo_form.go +++ b/modules/auth/repo_form.go @@ -46,6 +46,7 @@ type CreateRepoForm struct { Webhooks bool Avatar bool Labels bool + AutoAgree bool } // Validate validates the fields diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 7e674f2fd..e38fbe09f 100755 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1179,6 +1179,7 @@ template.topics = Topics template.avatar = Avatar template.issue_labels = Issue Labels template.one_item = Must select at least one template item +template.one_promise = Must agree to use the agreement! template.invalid = Must select a template repository template.repo_adress=Adress template.repo_path=path diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 0befaa8eb..e5fb97c8e 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -1189,6 +1189,7 @@ template.topics=主题 template.avatar=头像 template.issue_labels=任务标签 template.one_item=必须至少选择一个模板项 +template.one_promise=创建项目需承诺使用协议! template.invalid=必须选择一个模板项目 template.repo_adress=项目地址 template.repo_path=项目地址 diff --git a/routers/repo/repo.go b/routers/repo/repo.go index 70705dcf1..c0803ed06 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -6,7 +6,6 @@ package repo import ( - "code.gitea.io/gitea/modules/validation" "fmt" "net/url" "os" @@ -15,6 +14,8 @@ import ( "strings" "unicode/utf8" + "code.gitea.io/gitea/modules/validation" + "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/auth" "code.gitea.io/gitea/modules/base" @@ -193,7 +194,10 @@ func CreatePost(ctx *context.Context, form auth.CreateRepoForm) { return } ctx.Data["ContextUser"] = ctxUser - + if !form.AutoAgree { + ctx.RenderWithErr(ctx.Tr("repo.template.one_promise"), tplCreate, form) + return + } if ctx.HasError() { ctx.HTML(200, tplCreate) return