Example #1
0
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)
}
Example #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.AdminNoticePagingNum, page, 5)

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

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