1
1
mirror of https://github.com/go-gitea/gitea synced 2024-12-22 16:44:26 +00:00

#13 fix admin can't search private repos

- update glide info
This commit is contained in:
Unknwon 2016-03-15 14:23:12 -04:00
parent 9df5c39bca
commit 149d62a648
9 changed files with 99 additions and 41 deletions

View File

@ -3,7 +3,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra
![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true)
##### Current version: 0.9.9
##### Current version: 0.9.10
| Web | UI | Preview |
|:-------------:|:-------:|:-------:|

25
glide.lock generated
View File

@ -1,5 +1,5 @@
hash: 81254bce31966708f508a845836851efb77d96d8c522e745e67d0daeffd76cc5
updated: 2016-03-12T14:42:55.945562115-05:00
hash: f2fa73b9a379e1fa12f2b48fb0b9942a545b4518a2d71cbd956ee81093347773
updated: 2016-03-15T13:58:01.074601588-04:00
imports:
- name: github.com/bradfitz/gomemcache
version: fb1f79c6b65acda83063cbc69f6bba1522558bfc
@ -46,8 +46,10 @@ imports:
version: 788ec59749df076b98e208909b44fdef02779deb
- name: github.com/issue9/identicon
version: f8c0d2ce04db79c663b1da33d3a9f62be753ee88
- name: github.com/kardianos/minwinsvc
version: cad6b2b879b0970e4245a20ebf1a81a756e2bb70
- name: github.com/klauspost/compress
version: 2d3d403f37d2e70b722590bc286076a17422e1f2
version: 006acde2c5d283d2f8b8aa03d8f0cd2891c680cf
subpackages:
- gzip
- flate
@ -59,10 +61,14 @@ imports:
version: 165a3529e799da61ab10faed1fabff3662d6193f
subpackages:
- oid
- name: github.com/mattn/go-sqlite3
version: 76e335f60bbcee20755df9864f0153af1a80ad2d
- name: github.com/mcuadros/go-version
version: d52711f8d6bea8dc01efafdb68ad95a4e2606630
- name: github.com/microcosm-cc/bluemonday
version: 4ac6f27528d0a3f2a59e0b0a6f6b3ff0bb89fe20
- name: github.com/msteinert/pam
version: 02ccfbfaf0cc627aa3aec8ef7ed5cfeec5b43f63
- name: github.com/nfnt/resize
version: 4d93a29130b1b6aba503e2aa8b50f516213ea80e
- name: github.com/russross/blackfriday
@ -86,18 +92,23 @@ imports:
- name: github.com/Unknwon/paginater
version: 7748a72e01415173a27d79866b984328e7b0c12b
- name: golang.org/x/crypto
version: de93d05161db39bcbd84d3da2e54c4a18f37f0b1
version: 6025851c7c2bf210daf74d22300c699b16541847
subpackages:
- ssh
- curve25519
- name: golang.org/x/net
version: e7da8edaa52631091740908acaf2c2d4c9b3ce90
version: 35b06af0720201bc2f326773a80767387544f8c4
subpackages:
- html
- html/charset
- html/atom
- name: golang.org/x/sys
version: 9d4e42a20653790449273b3c85e67d6d8bae6e2e
subpackages:
- windows/svc
- windows
- name: golang.org/x/text
version: a71fd10341b064c10f4a81ceac72bcf70f26ea34
version: c20b6f20120f3c96689c10ffa47eee07776b9fe1
subpackages:
- transform
- encoding
@ -121,7 +132,7 @@ imports:
- name: gopkg.in/bufio.v1
version: 567b2bfa514e796916c4747494d6ff5132a1dfce
- name: gopkg.in/gomail.v2
version: 5ceb8e65415e45e1262fb385212b8193b55c0f99
version: afff51fd8cbc246672451a1b0b67e8f4a507bad8
- name: gopkg.in/ini.v1
version: 776aa739ce9373377cd16f526cdf06cb4c89b40f
- name: gopkg.in/ldap.v2

View File

@ -28,9 +28,12 @@ import:
- package: github.com/gogits/git-module
- package: github.com/gogits/go-gogs-client
- package: github.com/issue9/identicon
- package: github.com/kardianos/minwinsvc
- package: github.com/lib/pq
- package: github.com/mattn/go-sqlite3
- package: github.com/mcuadros/go-version
- package: github.com/microcosm-cc/bluemonday
- package: github.com/msteinert/pam
- package: github.com/nfnt/resize
- package: github.com/russross/blackfriday
- package: github.com/satori/go.uuid

View File

@ -17,7 +17,7 @@ import (
"github.com/gogits/gogs/modules/setting"
)
const APP_VER = "0.9.9.0313"
const APP_VER = "0.9.10.0315"
func init() {
runtime.GOMAXPROCS(runtime.NumCPU())

View File

@ -21,6 +21,12 @@ func Organizations(ctx *context.Context) {
ctx.Data["PageIsAdmin"] = true
ctx.Data["PageIsAdminOrganizations"] = true
routers.RenderUserSearch(ctx, models.USER_TYPE_ORGANIZATION, models.CountOrganizations, models.Organizations,
setting.AdminOrgPagingNum, "id ASC", ORGS)
routers.RenderUserSearch(ctx, &routers.UserSearchOptions{
Type: models.USER_TYPE_ORGANIZATION,
Counter: models.CountOrganizations,
Ranger: models.Organizations,
PageSize: setting.AdminOrgPagingNum,
OrderBy: "id ASC",
TplName: ORGS,
})
}

View File

@ -22,8 +22,14 @@ func Repos(ctx *context.Context) {
ctx.Data["PageIsAdmin"] = true
ctx.Data["PageIsAdminRepositories"] = true
routers.RenderRepoSearch(ctx, models.CountRepositories, models.Repositories,
setting.AdminRepoPagingNum, "id ASC", REPOS)
routers.RenderRepoSearch(ctx, &routers.RepoSearchOptions{
Counter: models.CountRepositories,
Ranger: models.Repositories,
Private: true,
PageSize: setting.AdminRepoPagingNum,
OrderBy: "id ASC",
TplName: REPOS,
})
}
func DeleteRepo(ctx *context.Context) {

View File

@ -30,8 +30,14 @@ func Users(ctx *context.Context) {
ctx.Data["PageIsAdmin"] = true
ctx.Data["PageIsAdminUsers"] = true
routers.RenderUserSearch(ctx, models.USER_TYPE_INDIVIDUAL, models.CountUsers, models.Users,
setting.AdminUserPagingNum, "id ASC", USERS)
routers.RenderUserSearch(ctx, &routers.UserSearchOptions{
Type: models.USER_TYPE_INDIVIDUAL,
Counter: models.CountUsers,
Ranger: models.Users,
PageSize: setting.AdminUserPagingNum,
OrderBy: "id ASC",
TplName: USERS,
})
}
func NewUser(ctx *context.Context) {

View File

@ -44,9 +44,16 @@ func Home(ctx *context.Context) {
ctx.HTML(200, HOME)
}
func RenderRepoSearch(ctx *context.Context,
counter func() int64, ranger func(int, int) ([]*models.Repository, error),
pagingNum int, orderBy string, tplName base.TplName) {
type RepoSearchOptions struct {
Counter func() int64
Ranger func(int, int) ([]*models.Repository, error)
Private bool
PageSize int
OrderBy string
TplName base.TplName
}
func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
page := ctx.QueryInt("page")
if page <= 1 {
page = 1
@ -60,18 +67,19 @@ func RenderRepoSearch(ctx *context.Context,
keyword := ctx.Query("q")
if len(keyword) == 0 {
repos, err = ranger(page, pagingNum)
repos, err = opts.Ranger(page, opts.PageSize)
if err != nil {
ctx.Handle(500, "ranger", err)
ctx.Handle(500, "opts.Ranger", err)
return
}
count = counter()
count = opts.Counter()
} else {
repos, count, err = models.SearchRepositoryByName(&models.SearchRepoOptions{
Keyword: keyword,
OrderBy: orderBy,
OrderBy: opts.OrderBy,
Private: opts.Private,
Page: page,
PageSize: pagingNum,
PageSize: opts.PageSize,
})
if err != nil {
ctx.Handle(500, "SearchRepositoryByName", err)
@ -80,7 +88,7 @@ func RenderRepoSearch(ctx *context.Context,
}
ctx.Data["Keyword"] = keyword
ctx.Data["Total"] = count
ctx.Data["Page"] = paginater.New(int(count), pagingNum, page, 5)
ctx.Data["Page"] = paginater.New(int(count), opts.PageSize, page, 5)
for _, repo := range repos {
if err = repo.GetOwner(); err != nil {
@ -90,7 +98,7 @@ func RenderRepoSearch(ctx *context.Context,
}
ctx.Data["Repos"] = repos
ctx.HTML(200, tplName)
ctx.HTML(200, opts.TplName)
}
func ExploreRepos(ctx *context.Context) {
@ -98,13 +106,25 @@ func ExploreRepos(ctx *context.Context) {
ctx.Data["PageIsExplore"] = true
ctx.Data["PageIsExploreRepositories"] = true
RenderRepoSearch(ctx, models.CountPublicRepositories, models.GetRecentUpdatedRepositories,
setting.ExplorePagingNum, "updated_unix DESC", EXPLORE_REPOS)
RenderRepoSearch(ctx, &RepoSearchOptions{
Counter: models.CountPublicRepositories,
Ranger: models.GetRecentUpdatedRepositories,
PageSize: setting.ExplorePagingNum,
OrderBy: "updated_unix DESC",
TplName: EXPLORE_REPOS,
})
}
func RenderUserSearch(ctx *context.Context, userType models.UserType,
counter func() int64, ranger func(int, int) ([]*models.User, error),
pagingNum int, orderBy string, tplName base.TplName) {
type UserSearchOptions struct {
Type models.UserType
Counter func() int64
Ranger func(int, int) ([]*models.User, error)
PageSize int
OrderBy string
TplName base.TplName
}
func RenderUserSearch(ctx *context.Context, opts *UserSearchOptions) {
page := ctx.QueryInt("page")
if page <= 1 {
page = 1
@ -118,19 +138,19 @@ func RenderUserSearch(ctx *context.Context, userType models.UserType,
keyword := ctx.Query("q")
if len(keyword) == 0 {
users, err = ranger(page, pagingNum)
users, err = opts.Ranger(page, opts.PageSize)
if err != nil {
ctx.Handle(500, "ranger", err)
ctx.Handle(500, "opts.Ranger", err)
return
}
count = counter()
count = opts.Counter()
} else {
users, count, err = models.SearchUserByName(&models.SearchUserOptions{
Keyword: keyword,
Type: userType,
OrderBy: orderBy,
Type: opts.Type,
OrderBy: opts.OrderBy,
Page: page,
PageSize: pagingNum,
PageSize: opts.PageSize,
})
if err != nil {
ctx.Handle(500, "SearchUserByName", err)
@ -139,10 +159,10 @@ func RenderUserSearch(ctx *context.Context, userType models.UserType,
}
ctx.Data["Keyword"] = keyword
ctx.Data["Total"] = count
ctx.Data["Page"] = paginater.New(int(count), pagingNum, page, 5)
ctx.Data["Page"] = paginater.New(int(count), opts.PageSize, page, 5)
ctx.Data["Users"] = users
ctx.HTML(200, tplName)
ctx.HTML(200, opts.TplName)
}
func ExploreUsers(ctx *context.Context) {
@ -150,8 +170,14 @@ func ExploreUsers(ctx *context.Context) {
ctx.Data["PageIsExplore"] = true
ctx.Data["PageIsExploreUsers"] = true
RenderUserSearch(ctx, models.USER_TYPE_INDIVIDUAL, models.CountUsers, models.Users,
setting.ExplorePagingNum, "updated_unix DESC", EXPLORE_USERS)
RenderUserSearch(ctx, &UserSearchOptions{
Type: models.USER_TYPE_INDIVIDUAL,
Counter: models.CountUsers,
Ranger: models.Users,
PageSize: setting.ExplorePagingNum,
OrderBy: "updated_unix DESC",
TplName: EXPLORE_USERS,
})
}
func NotFound(ctx *context.Context) {

View File

@ -1 +1 @@
0.9.9.0313
0.9.10.0315