2014-08-29 08:50:43 -04:00
|
|
|
// Copyright 2014 The Gogs Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a MIT-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package admin
|
|
|
|
|
|
|
|
import (
|
2015-09-25 13:54:52 -04:00
|
|
|
"github.com/Unknwon/paginater"
|
|
|
|
|
2014-08-29 08:50:43 -04:00
|
|
|
"github.com/gogits/gogs/models"
|
|
|
|
"github.com/gogits/gogs/modules/base"
|
2016-03-11 11:56:52 -05:00
|
|
|
"github.com/gogits/gogs/modules/context"
|
2015-09-25 13:54:52 -04:00
|
|
|
"github.com/gogits/gogs/modules/setting"
|
2014-08-29 08:50:43 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
ORGS base.TplName = "admin/org/list"
|
|
|
|
)
|
|
|
|
|
2016-03-11 11:56:52 -05:00
|
|
|
func Organizations(ctx *context.Context) {
|
2015-09-25 13:54:52 -04:00
|
|
|
ctx.Data["Title"] = ctx.Tr("admin.organizations")
|
2014-08-29 08:50:43 -04:00
|
|
|
ctx.Data["PageIsAdmin"] = true
|
|
|
|
ctx.Data["PageIsAdminOrganizations"] = true
|
|
|
|
|
2015-09-25 13:54:52 -04:00
|
|
|
total := models.CountOrganizations()
|
|
|
|
page := ctx.QueryInt("page")
|
|
|
|
if page <= 1 {
|
|
|
|
page = 1
|
|
|
|
}
|
|
|
|
ctx.Data["Page"] = paginater.New(int(total), setting.AdminOrgPagingNum, page, 5)
|
2016-03-11 11:56:52 -05:00
|
|
|
|
|
|
|
orgs, err := models.Organizations(page, setting.AdminOrgPagingNum)
|
|
|
|
|
2014-08-29 08:50:43 -04:00
|
|
|
if err != nil {
|
2015-09-25 13:54:52 -04:00
|
|
|
ctx.Handle(500, "Organizations", err)
|
2014-08-29 08:50:43 -04:00
|
|
|
return
|
|
|
|
}
|
2016-03-11 11:56:52 -05:00
|
|
|
|
|
|
|
ctx.Data["Orgs"] = orgs
|
2015-09-25 13:54:52 -04:00
|
|
|
ctx.Data["Total"] = total
|
|
|
|
|
2014-08-29 08:50:43 -04:00
|
|
|
ctx.HTML(200, ORGS)
|
|
|
|
}
|