From 14a11011390000cc21d134c3e612dda0fb9f490c Mon Sep 17 00:00:00 2001 From: Antoine GIRARD Date: Fri, 25 Sep 2015 18:13:38 +0200 Subject: New admin notice UI based on user list example --- routers/admin/notice.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'routers/admin/notice.go') diff --git a/routers/admin/notice.go b/routers/admin/notice.go index b431946366..b3cadc254d 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) } -- cgit v1.2.3 From 3544dafb649c798736991f813593c10584e18e34 Mon Sep 17 00:00:00 2001 From: Antoine GIRARD Date: Fri, 25 Sep 2015 18:39:31 +0200 Subject: Fix indent --- routers/admin/notice.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'routers/admin/notice.go') diff --git a/routers/admin/notice.go b/routers/admin/notice.go index b3cadc254d..164badda7b 100644 --- a/routers/admin/notice.go +++ b/routers/admin/notice.go @@ -6,7 +6,7 @@ package admin import ( "github.com/Unknwon/com" - "github.com/Unknwon/paginater" + "github.com/Unknwon/paginater" "github.com/gogits/gogs/models" "github.com/gogits/gogs/modules/base" -- cgit v1.2.3