summaryrefslogtreecommitdiffstats
path: root/routers/admin
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2016-03-11 15:33:12 -0500
committerUnknwon <u@gogs.io>2016-03-11 15:33:12 -0500
commit2bf8494332592b3c57f9a12a26b9abd356fb3f15 (patch)
treee46c61ba30018ebbafcda6b97b36d3ffece3cfb0 /routers/admin
parentdf2bdf7ea36ad0729e0326ca799d8896d7f96946 (diff)
downloadgitea-2bf8494332592b3c57f9a12a26b9abd356fb3f15.tar.gz
gitea-2bf8494332592b3c57f9a12a26b9abd356fb3f15.zip
#13 finish user and repository search
Both are possible on explore and admin panel
Diffstat (limited to 'routers/admin')
-rw-r--r--routers/admin/orgs.go23
-rw-r--r--routers/admin/repos.go21
-rw-r--r--routers/admin/users.go20
3 files changed, 9 insertions, 55 deletions
diff --git a/routers/admin/orgs.go b/routers/admin/orgs.go
index 829e78e83c..395243a5f7 100644
--- a/routers/admin/orgs.go
+++ b/routers/admin/orgs.go
@@ -5,12 +5,11 @@
package admin
import (
- "github.com/Unknwon/paginater"
-
"github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/context"
"github.com/gogits/gogs/modules/setting"
+ "github.com/gogits/gogs/routers"
)
const (
@@ -22,22 +21,6 @@ func Organizations(ctx *context.Context) {
ctx.Data["PageIsAdmin"] = true
ctx.Data["PageIsAdminOrganizations"] = true
- 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, "Organizations", err)
- return
- }
-
- ctx.Data["Orgs"] = orgs
- ctx.Data["Total"] = total
-
- ctx.HTML(200, ORGS)
+ routers.RenderUserSearch(ctx, models.USER_TYPE_ORGANIZATION, models.CountOrganizations, models.Organizations,
+ setting.AdminOrgPagingNum, "id ASC", ORGS)
}
diff --git a/routers/admin/repos.go b/routers/admin/repos.go
index 47b6032a65..e78941ab4c 100644
--- a/routers/admin/repos.go
+++ b/routers/admin/repos.go
@@ -5,13 +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/context"
"github.com/gogits/gogs/modules/log"
"github.com/gogits/gogs/modules/setting"
+ "github.com/gogits/gogs/routers"
)
const (
@@ -23,22 +22,8 @@ func Repos(ctx *context.Context) {
ctx.Data["PageIsAdmin"] = true
ctx.Data["PageIsAdminRepositories"] = true
- total := models.CountRepositories()
- page := ctx.QueryInt("page")
- if page <= 1 {
- page = 1
- }
- ctx.Data["Page"] = paginater.New(int(total), setting.AdminRepoPagingNum, page, 5)
-
- repos, err := models.RepositoriesWithUsers(page, setting.AdminRepoPagingNum)
- if err != nil {
- ctx.Handle(500, "RepositoriesWithUsers", err)
- return
- }
- ctx.Data["Repos"] = repos
-
- ctx.Data["Total"] = total
- ctx.HTML(200, REPOS)
+ routers.RenderRepoSearch(ctx, models.CountRepositories, models.Repositories,
+ setting.AdminRepoPagingNum, "id ASC", REPOS)
}
func DeleteRepo(ctx *context.Context) {
diff --git a/routers/admin/users.go b/routers/admin/users.go
index 274effc4b6..00028a2fdd 100644
--- a/routers/admin/users.go
+++ b/routers/admin/users.go
@@ -8,7 +8,6 @@ import (
"strings"
"github.com/Unknwon/com"
- "github.com/Unknwon/paginater"
"github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/auth"
@@ -17,6 +16,7 @@ import (
"github.com/gogits/gogs/modules/log"
"github.com/gogits/gogs/modules/mailer"
"github.com/gogits/gogs/modules/setting"
+ "github.com/gogits/gogs/routers"
)
const (
@@ -30,22 +30,8 @@ func Users(ctx *context.Context) {
ctx.Data["PageIsAdmin"] = true
ctx.Data["PageIsAdminUsers"] = true
- total := models.CountUsers()
- page := ctx.QueryInt("page")
- if page <= 1 {
- page = 1
- }
- ctx.Data["Page"] = paginater.New(int(total), setting.AdminUserPagingNum, page, 5)
-
- users, err := models.Users(page, setting.AdminUserPagingNum)
- if err != nil {
- ctx.Handle(500, "Users", err)
- return
- }
- ctx.Data["Users"] = users
-
- ctx.Data["Total"] = total
- ctx.HTML(200, USERS)
+ routers.RenderUserSearch(ctx, models.USER_TYPE_INDIVIDUAL, models.CountUsers, models.Users,
+ setting.AdminUserPagingNum, "id ASC", USERS)
}
func NewUser(ctx *context.Context) {