Browse Source

#1253 : filter organisation repositories by label

pull/5260/head
isundil 7 years ago
parent
commit
929fca8d5d
  1. 11
      routes/user/home.go
  2. 2
      templates/repo/header.tmpl

11
routes/user/home.go

@ -379,7 +379,8 @@ func showOrgProfile(c *context.Context) {
count int64 count int64
err error 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) repos, count, err = org.GetUserRepositories(c.User.ID, page, setting.UI.User.RepoPagingNum)
if err != nil { if err != nil {
c.Handle(500, "GetUserRepositories", err) c.Handle(500, "GetUserRepositories", err)
@ -388,10 +389,18 @@ func showOrgProfile(c *context.Context) {
c.Data["Repos"] = repos c.Data["Repos"] = repos
} else { } else {
showPrivate := c.IsLogged && c.User.IsAdmin 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{ repos, err = models.GetUserRepositories(&models.UserRepoOptions{
UserID: org.ID, UserID: org.ID,
Private: showPrivate, Private: showPrivate,
Page: page, Page: page,
LabelID: labelID,
PageSize: setting.UI.User.RepoPagingNum, PageSize: setting.UI.User.RepoPagingNum,
}) })
if err != nil { if err != nil {

2
templates/repo/header.tmpl

@ -46,7 +46,7 @@
</div> </div>
<div class="label-list"> <div class="label-list">
{{range $.RepositoryLabels}} {{range $.RepositoryLabels}}
<a class="ui label" style="background-color:{{.Color}}; color:{{.ForegroundColor}}" href="{{AppSubURL}}/{{.GetOwner.Name}}/labels/{{.ID}}">{{.Name}}</a> <a class="ui label" style="background-color:{{.Color}}; color:{{.ForegroundColor}}" href="{{AppSubURL}}/{{$.Owner.Name}}/labels/{{.ID}}">{{.Name}}</a>
{{end}} {{end}}
</div> </div>
</div><!-- end column --> </div><!-- end column -->

Loading…
Cancel
Save