diff options
author | Unknwon <joe2010xtmf@163.com> | 2014-12-12 20:30:32 -0500 |
---|---|---|
committer | Unknwon <joe2010xtmf@163.com> | 2014-12-12 20:30:32 -0500 |
commit | ac4a10456ea4515091c3c90a83a82c1e59cdf428 (patch) | |
tree | db68f1f7a8f290322bd4da9892487cca5a1a5843 /models/org.go | |
parent | 2f3a7e53cb58e922055baf3cf14138100a1f05ac (diff) | |
download | gitea-ac4a10456ea4515091c3c90a83a82c1e59cdf428.tar.gz gitea-ac4a10456ea4515091c3c90a83a82c1e59cdf428.zip |
api: able to create repo and fix #726
- POST /user/repos
- POST /org/:org/repos
Diffstat (limited to 'models/org.go')
-rw-r--r-- | models/org.go | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/models/org.go b/models/org.go index 41611f8116..5431a111c3 100644 --- a/models/org.go +++ b/models/org.go @@ -25,8 +25,8 @@ var ( ErrLastOrgOwner = errors.New("The user to remove is the last member in owner team") ) -// IsOrgOwner returns true if given user is in the owner team. -func (org *User) IsOrgOwner(uid int64) bool { +// IsOwnedBy returns true if given user is in the owner team. +func (org *User) IsOwnedBy(uid int64) bool { return IsOrganizationOwner(org.Id, uid) } @@ -170,6 +170,24 @@ func CreateOrganization(org, owner *User) (*User, error) { return org, sess.Commit() } +// GetOrgByName returns organization by given name. +func GetOrgByName(name string) (*User, error) { + if len(name) == 0 { + return nil, ErrOrgNotExist + } + u := &User{ + LowerName: strings.ToLower(name), + Type: ORGANIZATION, + } + has, err := x.Get(u) + if err != nil { + return nil, err + } else if !has { + return nil, ErrOrgNotExist + } + return u, nil +} + // CountOrganizations returns number of organizations. func CountOrganizations() int64 { count, _ := x.Where("type=1").Count(new(User)) |