Skip to content

Commit

Permalink
Fix orgs not being displayed on create repo form (#11279)
Browse files Browse the repository at this point in the history
  • Loading branch information
CirnoT committed May 3, 2020
1 parent ce66ca7 commit b7c82cd
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions routers/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit b7c82cd

Please sign in to comment.