summaryrefslogtreecommitdiffstats
path: root/routers/admin/notice.go
diff options
context:
space:
mode:
author无闻 <u@gogs.io>2015-09-25 12:53:18 -0400
committer无闻 <u@gogs.io>2015-09-25 12:53:18 -0400
commit1c35380c2c476e8eb5022078262e8cadade4d4c7 (patch)
treed4ee03e2655e96b8ea87bfb21a58591bbd293b65 /routers/admin/notice.go
parent4f8b20995694a21cdde1c2be3b86de8186fe3f42 (diff)
parent3544dafb649c798736991f813593c10584e18e34 (diff)
downloadgitea-1c35380c2c476e8eb5022078262e8cadade4d4c7.tar.gz
gitea-1c35380c2c476e8eb5022078262e8cadade4d4c7.zip
Merge pull request #1689 from sapk/fix-admin-notice-new-ui
New admin notice UI based on user list example
Diffstat (limited to 'routers/admin/notice.go')
-rw-r--r--routers/admin/notice.go17
1 files changed, 12 insertions, 5 deletions
diff --git a/routers/admin/notice.go b/routers/admin/notice.go
index b431946366..164badda7b 100644
--- a/routers/admin/notice.go
+++ b/routers/admin/notice.go
@@ -6,11 +6,13 @@ package admin
import (
"github.com/Unknwon/com"
+ "github.com/Unknwon/paginater"
"github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/log"
"github.com/gogits/gogs/modules/middleware"
+ "github.com/gogits/gogs/modules/setting"
)
const (
@@ -22,15 +24,20 @@ func Notices(ctx *middleware.Context) {
ctx.Data["PageIsAdmin"] = true
ctx.Data["PageIsAdminNotices"] = true
- pageNum := 50
- p := pagination(ctx, models.CountNotices(), pageNum)
-
- notices, err := models.GetNotices(pageNum, (p-1)*pageNum)
+ total := models.CountNotices()
+ page := ctx.QueryInt("page")
+ if page <= 1 {
+ page = 1
+ }
+ ctx.Data["Page"] = paginater.New(int(total), setting.AdminNoticePagingNum, page, 5)
+
+ notices, err := models.Notices(page, setting.AdminNoticePagingNum)
if err != nil {
- ctx.Handle(500, "GetNotices", err)
+ ctx.Handle(500, "Notices", err)
return
}
ctx.Data["Notices"] = notices
+ ctx.Data["Total"] = total
ctx.HTML(200, NOTICES)
}