diff options
author | Unknwon <u@gogs.io> | 2015-12-17 02:28:47 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-12-17 02:28:47 -0500 |
commit | 9cd16c5b12d093dd694e146d6c845ee4c405c774 (patch) | |
tree | d9f1a037ba8ecbc3e5fe2f15f0baec6dec6242b4 /models | |
parent | 6673dcb0380aa99da25b4d1d68cf129635fe30d9 (diff) | |
download | gitea-9cd16c5b12d093dd694e146d6c845ee4c405c774.tar.gz gitea-9cd16c5b12d093dd694e146d6c845ee4c405c774.zip |
#1692 add organization APIs
Diffstat (limited to 'models')
-rw-r--r-- | models/org.go | 11 | ||||
-rw-r--r-- | models/user.go | 4 |
2 files changed, 10 insertions, 5 deletions
diff --git a/models/org.go b/models/org.go index 6cc951bef0..fa26b59e66 100644 --- a/models/org.go +++ b/models/org.go @@ -274,10 +274,15 @@ func GetOwnedOrgsByUserIDDesc(userID int64, desc string) ([]*User, error) { return getOwnedOrgsByUserID(sess.Desc(desc), userID) } -// GetOrgUsersByUserId returns all organization-user relations by user ID. -func GetOrgUsersByUserId(uid int64) ([]*OrgUser, error) { +// GetOrgUsersByUserID returns all organization-user relations by user ID. +func GetOrgUsersByUserID(uid int64, all bool) ([]*OrgUser, error) { ous := make([]*OrgUser, 0, 10) - err := x.Where("uid=?", uid).Find(&ous) + sess := x.Where("uid=?", uid) + if !all { + // Only show public organizations + sess.And("is_public=?", true) + } + err := sess.Find(&ous) return ous, err } diff --git a/models/user.go b/models/user.go index 71729a4e3e..ebdc3c47fe 100644 --- a/models/user.go +++ b/models/user.go @@ -376,8 +376,8 @@ func (u *User) GetOwnedOrganizations() (err error) { } // GetOrganizations returns all organizations that user belongs to. -func (u *User) GetOrganizations() error { - ous, err := GetOrgUsersByUserId(u.Id) +func (u *User) GetOrganizations(all bool) error { + ous, err := GetOrgUsersByUserID(u.Id, all) if err != nil { return err } |