From 929fca8d5dbf8d7d042fdc07bbf3e111a791c22e Mon Sep 17 00:00:00 2001 From: isundil Date: Sun, 8 Apr 2018 22:55:59 +0000 Subject: [PATCH] #1253 : filter organisation repositories by label --- routes/user/home.go | 11 ++++++++++- templates/repo/header.tmpl | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/routes/user/home.go b/routes/user/home.go index 1f3e0b8a6..3b101159d 100644 --- a/routes/user/home.go +++ b/routes/user/home.go @@ -379,7 +379,8 @@ func showOrgProfile(c *context.Context) { count int64 err error ) - if c.IsLogged && !c.User.IsAdmin { + labelID := c.ParamsInt64(":labelID") + if c.IsLogged && !c.User.IsAdmin && labelID == 0 { repos, count, err = org.GetUserRepositories(c.User.ID, page, setting.UI.User.RepoPagingNum) if err != nil { c.Handle(500, "GetUserRepositories", err) @@ -388,10 +389,18 @@ func showOrgProfile(c *context.Context) { c.Data["Repos"] = repos } else { showPrivate := c.IsLogged && c.User.IsAdmin + if labelID != 0 { + label, err := models.GetRepositoryLabelById(labelID) + if err != nil || (label.IsPrivate && !showPrivate) { + c.NotFound() + return + } + } repos, err = models.GetUserRepositories(&models.UserRepoOptions{ UserID: org.ID, Private: showPrivate, Page: page, + LabelID: labelID, PageSize: setting.UI.User.RepoPagingNum, }) if err != nil { diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index 631a44a07..b65dc86df 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -46,7 +46,7 @@
{{range $.RepositoryLabels}} - {{.Name}} + {{.Name}} {{end}}