diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go index 199651b2f125a..0a9a77c9ff916 100644 --- a/routers/web/repo/repo.go +++ b/routers/web/repo/repo.go @@ -146,7 +146,6 @@ func Create(ctx *context.Context) { if ctx.Written() { return } - ctx.Data["ContextUser"] = ctxUser ctx.Data["repo_template_name"] = ctx.Tr("repo.template_select") templateID := ctx.FormInt64("template_id") @@ -158,8 +157,17 @@ func Create(ctx *context.Context) { } } - ctx.Data["CanCreateRepo"] = ctx.Doer.CanCreateRepo() + canCreateRepo := ctx.Doer.CanCreateRepo() + if !canCreateRepo && ctx.Doer.ID == ctxUser.ID { + orgs, has := ctx.Data["Orgs"].([]*organization.Organization) + if has && len(orgs) > 0 { + ctxUser = orgs[0].AsUser() + } + } + + ctx.Data["CanCreateRepo"] = canCreateRepo ctx.Data["MaxCreationLimit"] = ctx.Doer.MaxCreationLimit() + ctx.Data["ContextUser"] = ctxUser ctx.HTML(http.StatusOK, tplCreate) } diff --git a/templates/repo/create.tmpl b/templates/repo/create.tmpl index c250b0d4a988c..8746c8ef8ca18 100644 --- a/templates/repo/create.tmpl +++ b/templates/repo/create.tmpl @@ -14,7 +14,7 @@
{{.i18n.Tr "repo.new_repo_helper" ((printf "%s%s" AppSubUrl "/repo/migrate")|Escape) | Safe}}
{{end}} - {{if not .CanCreateRepo}} + {{if and (not .CanCreateRepo) (not .Orgs)}} @@ -29,10 +29,12 @@ {{svg "octicon-triangle-down" 14 "dropdown icon"}}