From b7c82cd1a9ce4f863034a3a59312ff9402a8f72c Mon Sep 17 00:00:00 2001 From: Cirno the Strongest <1447794+CirnoT@users.noreply.github.com> Date: Sun, 3 May 2020 23:08:24 +0200 Subject: [PATCH] Fix orgs not being displayed on create repo form (#11279) --- routers/repo/repo.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/routers/repo/repo.go b/routers/repo/repo.go index 994beef7af..b0bb608d09 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -62,6 +62,18 @@ func checkContextUser(ctx *context.Context, uid int64) *models.User { return nil } + if !ctx.User.IsAdmin { + orgsAvailable := []*models.User{} + for i := 0; i < len(orgs); i++ { + if orgs[i].CanCreateRepo() { + orgsAvailable = append(orgsAvailable, orgs[i]) + } + } + ctx.Data["Orgs"] = orgsAvailable + } else { + ctx.Data["Orgs"] = orgs + } + // Not equal means current user is an organization. if uid == ctx.User.ID || uid == 0 { return ctx.User @@ -83,14 +95,6 @@ func checkContextUser(ctx *context.Context, uid int64) *models.User { return nil } if !ctx.User.IsAdmin { - orgsAvailable := []*models.User{} - for i := 0; i < len(orgs); i++ { - if orgs[i].CanCreateRepo() { - orgsAvailable = append(orgsAvailable, orgs[i]) - } - } - ctx.Data["Orgs"] = orgsAvailable - canCreate, err := org.CanCreateOrgRepo(ctx.User.ID) if err != nil { ctx.ServerError("CanCreateOrgRepo", err)