diff options
Diffstat (limited to 'routers')
-rw-r--r-- | routers/admin/notice.go | 10 | ||||
-rw-r--r-- | routers/admin/orgs.go | 25 |
2 files changed, 23 insertions, 12 deletions
diff --git a/routers/admin/notice.go b/routers/admin/notice.go index 164badda7b..512c3f5993 100644 --- a/routers/admin/notice.go +++ b/routers/admin/notice.go @@ -5,7 +5,6 @@ package admin import ( - "github.com/Unknwon/com" "github.com/Unknwon/paginater" "github.com/gogits/gogs/models" @@ -24,25 +23,26 @@ func Notices(ctx *middleware.Context) { ctx.Data["PageIsAdmin"] = true ctx.Data["PageIsAdminNotices"] = true - total := models.CountNotices() + 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) + + 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) } func DeleteNotice(ctx *middleware.Context) { - id := com.StrTo(ctx.Params(":id")).MustInt64() + id := ctx.ParamsInt64(":id") if err := models.DeleteNotice(id); err != nil { ctx.Handle(500, "DeleteNotice", err) return diff --git a/routers/admin/orgs.go b/routers/admin/orgs.go index 54d7af5cb3..ae68b872d0 100644 --- a/routers/admin/orgs.go +++ b/routers/admin/orgs.go @@ -5,9 +5,12 @@ package admin import ( + "github.com/Unknwon/paginater" + "github.com/gogits/gogs/models" "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/middleware" + "github.com/gogits/gogs/modules/setting" ) const ( @@ -15,18 +18,26 @@ const ( ) func Organizations(ctx *middleware.Context) { - ctx.Data["Title"] = ctx.Tr("admin.orgs") + ctx.Data["Title"] = ctx.Tr("admin.organizations") ctx.Data["PageIsAdmin"] = true ctx.Data["PageIsAdminOrganizations"] = true - pageNum := 50 - p := pagination(ctx, models.CountOrganizations(), pageNum) - - var err error - ctx.Data["Orgs"], err = models.GetOrganizations(pageNum, (p-1)*pageNum) + total := models.CountOrganizations() + page := ctx.QueryInt("page") + if page <= 1 { + page = 1 + } + ctx.Data["Page"] = paginater.New(int(total), setting.AdminOrgPagingNum, page, 5) + + orgs, err := models.Organizations(page, setting.AdminOrgPagingNum) + if err != nil { - ctx.Handle(500, "GetOrganizations", err) + ctx.Handle(500, "Organizations", err) return } + + ctx.Data["Orgs"] = orgs + ctx.Data["Total"] = total + ctx.HTML(200, ORGS) } |