summaryrefslogtreecommitdiffstats
path: root/routers/repo/release.go
diff options
context:
space:
mode:
authoriszla <iszla@users.noreply.github.com>2017-06-28 16:47:00 +0200
committerLunny Xiao <xiaolunwen@gmail.com>2017-06-28 22:47:00 +0800
commit3f9016430f5a712bdff05a9cc941a287be0f217d (patch)
tree874a5bb1a3823a7e74590a6212968ea12384fe25 /routers/repo/release.go
parent1f4d84b7b26c08e5a0e3abbaac650ac39d48c9d3 (diff)
downloadgitea-3f9016430f5a712bdff05a9cc941a287be0f217d.tar.gz
gitea-3f9016430f5a712bdff05a9cc941a287be0f217d.zip
Pagination on releases page (#2035)
* Added count to GetReleasesByRepoID so pagination will work * Separated it out to a new function, can then also leave the API part unaffected * Remove extra whitespace added in untouched function * Added comment and corrected name in error handler * Account for if the user is owner or not in the count * Also check if repo is draft * revert back to the correct count in the ReleasesToDisplay loop * Fixed lint error regarding else with return statement * Use Cond struct instead of string, corrected name in error handler * Removed unused return variable names
Diffstat (limited to 'routers/repo/release.go')
-rw-r--r--routers/repo/release.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/routers/repo/release.go b/routers/repo/release.go
index 093fec539a..1b2c630a56 100644
--- a/routers/repo/release.go
+++ b/routers/repo/release.go
@@ -67,7 +67,13 @@ func Releases(ctx *context.Context) {
releases, err := models.GetReleasesByRepoID(ctx.Repo.Repository.ID, page, limit)
if err != nil {
- ctx.Handle(500, "GetReleasesByRepoIDAndNames", err)
+ ctx.Handle(500, "GetReleasesByRepoID", err)
+ return
+ }
+
+ count, err := models.GetReleaseCountByRepoID(ctx.Repo.Repository.ID, ctx.Repo.IsOwner())
+ if err != nil {
+ ctx.Handle(500, "GetReleaseCountByRepoID", err)
return
}
@@ -110,7 +116,7 @@ func Releases(ctx *context.Context) {
releasesToDisplay = append(releasesToDisplay, r)
}
- pager := paginater.New(len(releasesToDisplay), limit, page, 5)
+ pager := paginater.New(int(count), limit, page, 5)
ctx.Data["Page"] = pager
ctx.Data["Releases"] = releasesToDisplay
ctx.HTML(200, tplReleases)