mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-05 09:55:20 +02:00
api: able to create repo and fix #726
- POST /user/repos - POST /org/:org/repos
This commit is contained in:
parent
2f3a7e53cb
commit
ac4a10456e
14 changed files with 162 additions and 81 deletions
|
@ -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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue