summaryrefslogtreecommitdiffstats
path: root/models/org.go
diff options
context:
space:
mode:
authorBwko <bouwko@gmail.com>2016-12-24 15:42:26 +0100
committerLunny Xiao <xiaolunwen@gmail.com>2016-12-24 22:42:26 +0800
commitfa3abc22c06843bb27089e8c0f7aebf0f5d83fcc (patch)
treef7763df24980f419698ea75f4cd2d080784a62d2 /models/org.go
parentc1e92eeb72fe92cc30c80985e5e2b970f4735067 (diff)
downloadgitea-fa3abc22c06843bb27089e8c0f7aebf0f5d83fcc.tar.gz
gitea-fa3abc22c06843bb27089e8c0f7aebf0f5d83fcc.zip
Added sorting to organizations, repos & users page (#222)
Diffstat (limited to 'models/org.go')
-rw-r--r--models/org.go19
1 files changed, 13 insertions, 6 deletions
diff --git a/models/org.go b/models/org.go
index 9908386f0d..b302288ca5 100644
--- a/models/org.go
+++ b/models/org.go
@@ -195,12 +195,19 @@ func CountOrganizations() int64 {
}
// Organizations returns number of organizations in given page.
-func Organizations(page, pageSize int) ([]*User, error) {
- orgs := make([]*User, 0, pageSize)
- return orgs, x.
- Limit(pageSize, (page-1)*pageSize).
- Where("type=1").
- Asc("name").
+func Organizations(opts *SearchUserOptions) ([]*User, error) {
+ orgs := make([]*User, 0, opts.PageSize)
+
+ if len(opts.OrderBy) == 0 {
+ opts.OrderBy = "name ASC"
+ }
+
+ sess := x.
+ Limit(opts.PageSize, (opts.Page-1)*opts.PageSize).
+ Where("type=1")
+
+ return orgs, sess.
+ OrderBy(opts.OrderBy).
Find(&orgs)
}