summaryrefslogtreecommitdiffstats
path: root/routers/repo
diff options
context:
space:
mode:
authorLauris BH <lauris@nix.lv>2017-06-29 18:11:38 +0300
committerLunny Xiao <xiaolunwen@gmail.com>2017-06-29 23:11:38 +0800
commit783b1967e257fdba2bd593d9f2108da2010b7448 (patch)
treece6b942c92ee7a45ffbca29cdd1dd0dae3964df8 /routers/repo
parent33f3165296613c819ed82612da2f6738c1301ec1 (diff)
downloadgitea-783b1967e257fdba2bd593d9f2108da2010b7448.tar.gz
gitea-783b1967e257fdba2bd593d9f2108da2010b7448.zip
Fix release display and correct paging (#2080)
Diffstat (limited to 'routers/repo')
-rw-r--r--routers/repo/release.go15
1 files changed, 7 insertions, 8 deletions
diff --git a/routers/repo/release.go b/routers/repo/release.go
index 1b2c630a56..d9cc967801 100644
--- a/routers/repo/release.go
+++ b/routers/repo/release.go
@@ -65,13 +65,17 @@ func Releases(ctx *context.Context) {
limit = 10
}
- releases, err := models.GetReleasesByRepoID(ctx.Repo.Repository.ID, page, limit)
+ opts := models.FindReleasesOptions{
+ IncludeDrafts: ctx.Repo.IsWriter(),
+ }
+
+ releases, err := models.GetReleasesByRepoID(ctx.Repo.Repository.ID, opts, page, limit)
if err != nil {
ctx.Handle(500, "GetReleasesByRepoID", err)
return
}
- count, err := models.GetReleaseCountByRepoID(ctx.Repo.Repository.ID, ctx.Repo.IsOwner())
+ count, err := models.GetReleaseCountByRepoID(ctx.Repo.Repository.ID, opts)
if err != nil {
ctx.Handle(500, "GetReleaseCountByRepoID", err)
return
@@ -91,11 +95,7 @@ func Releases(ctx *context.Context) {
}
var ok bool
- releasesToDisplay := make([]*models.Release, 0, len(releases))
for _, r := range releases {
- if r.IsDraft && !ctx.Repo.IsOwner() {
- continue
- }
if r.Publisher, ok = cacheUsers[r.PublisherID]; !ok {
r.Publisher, err = models.GetUserByID(r.PublisherID)
if err != nil {
@@ -113,12 +113,11 @@ func Releases(ctx *context.Context) {
return
}
r.Note = markdown.RenderString(r.Note, ctx.Repo.RepoLink, ctx.Repo.Repository.ComposeMetas())
- releasesToDisplay = append(releasesToDisplay, r)
}
pager := paginater.New(int(count), limit, page, 5)
ctx.Data["Page"] = pager
- ctx.Data["Releases"] = releasesToDisplay
+ ctx.Data["Releases"] = releases
ctx.HTML(200, tplReleases)
}