diff options
author | Lauris BH <lauris@nix.lv> | 2017-06-29 18:11:38 +0300 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-06-29 23:11:38 +0800 |
commit | 783b1967e257fdba2bd593d9f2108da2010b7448 (patch) | |
tree | ce6b942c92ee7a45ffbca29cdd1dd0dae3964df8 /routers/api | |
parent | 33f3165296613c819ed82612da2f6738c1301ec1 (diff) | |
download | gitea-783b1967e257fdba2bd593d9f2108da2010b7448.tar.gz gitea-783b1967e257fdba2bd593d9f2108da2010b7448.zip |
Fix release display and correct paging (#2080)
Diffstat (limited to 'routers/api')
-rw-r--r-- | routers/api/v1/repo/release.go | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/routers/api/v1/repo/release.go b/routers/api/v1/repo/release.go index a367e55717..ed5b8f4f78 100644 --- a/routers/api/v1/repo/release.go +++ b/routers/api/v1/repo/release.go @@ -34,22 +34,21 @@ func GetRelease(ctx *context.APIContext) { // ListReleases list a repository's releases func ListReleases(ctx *context.APIContext) { - releases, err := models.GetReleasesByRepoID(ctx.Repo.Repository.ID, 1, 2147483647) + access, err := models.AccessLevel(ctx.User.ID, ctx.Repo.Repository) if err != nil { - ctx.Error(500, "GetReleasesByRepoID", err) + ctx.Error(500, "AccessLevel", err) return } - rels := make([]*api.Release, len(releases)) - access, err := models.AccessLevel(ctx.User.ID, ctx.Repo.Repository) + + releases, err := models.GetReleasesByRepoID(ctx.Repo.Repository.ID, models.FindReleasesOptions{ + IncludeDrafts: access >= models.AccessModeWrite, + }, 1, 2147483647) if err != nil { - ctx.Error(500, "AccessLevel", err) + ctx.Error(500, "GetReleasesByRepoID", err) return } + rels := make([]*api.Release, len(releases)) for i, release := range releases { - if release.IsDraft && access < models.AccessModeWrite { - // hide drafts from users without push access - continue - } if err := release.LoadAttributes(); err != nil { ctx.Error(500, "LoadAttributes", err) return |