api: able to create repo and fix #726

- POST /user/repos
- POST /org/:org/repos
This commit is contained in:
Unknwon 2014-12-12 20:30:32 -05:00
parent 2f3a7e53cb
commit ac4a10456e
14 changed files with 162 additions and 81 deletions

View file

@ -97,14 +97,14 @@ func CreatePost(ctx *middleware.Context, form auth.CreateRepoForm) {
if ctxUser.IsOrganization() {
// Check ownership of organization.
if !ctxUser.IsOrgOwner(ctx.User.Id) {
if !ctxUser.IsOwnedBy(ctx.User.Id) {
ctx.Error(403)
return
}
}
repo, err := models.CreateRepository(ctxUser, form.RepoName, form.Description,
form.Gitignore, form.License, form.Private, false, form.InitReadme)
form.Gitignore, form.License, form.Private, false, form.AutoInit)
if err == nil {
log.Trace("Repository created: %s/%s", ctxUser.Name, repo.Name)
ctx.Redirect(setting.AppSubUrl + "/" + ctxUser.Name + "/" + repo.Name)
@ -174,7 +174,7 @@ func MigratePost(ctx *middleware.Context, form auth.MigrateRepoForm) {
if ctxUser.IsOrganization() {
// Check ownership of organization.
if !ctxUser.IsOrgOwner(ctx.User.Id) {
if !ctxUser.IsOwnedBy(ctx.User.Id) {
ctx.Error(403)
return
}
@ -292,7 +292,7 @@ func ForkPost(ctx *middleware.Context, form auth.CreateRepoForm) {
if ctxUser.IsOrganization() {
// Check ownership of organization.
if !ctxUser.IsOrgOwner(ctx.User.Id) {
if !ctxUser.IsOwnedBy(ctx.User.Id) {
ctx.Error(403)
return
}