New admin notice UI based on user list example
This commit is contained in:
parent
4f8b209956
commit
14a1101139
5 changed files with 83 additions and 63 deletions
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue