示例#1
0
文件: notice.go 项目: noikiy/gitea
func Notices(ctx *middleware.Context) {
	ctx.Data["Title"] = ctx.Tr("admin.notices")
	ctx.Data["PageIsAdmin"] = true
	ctx.Data["PageIsAdminNotices"] = true

	pageNum := 50
	p := pagination(ctx, models.CountNotices(), pageNum)

	notices, err := models.GetNotices(pageNum, (p-1)*pageNum)
	if err != nil {
		ctx.Handle(500, "GetNotices", err)
		return
	}
	ctx.Data["Notices"] = notices
	ctx.HTML(200, NOTICES)
}
示例#2
0
func Notices(ctx *context.Context) {
	ctx.Data["Title"] = ctx.Tr("admin.notices")
	ctx.Data["PageIsAdmin"] = true
	ctx.Data["PageIsAdminNotices"] = true

	total := models.CountNotices()
	page := ctx.QueryInt("page")
	if page <= 1 {
		page = 1
	}
	ctx.Data["Page"] = paginater.New(int(total), setting.UI.Admin.NoticePagingNum, page, 5)

	notices, err := models.Notices(page, setting.UI.Admin.NoticePagingNum)
	if err != nil {
		ctx.Handle(500, "Notices", err)
		return
	}
	ctx.Data["Notices"] = notices

	ctx.Data["Total"] = total
	ctx.HTML(200, NOTICES)
}