summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-12-10 12:37:53 -0500
committerUnknwon <u@gogs.io>2015-12-10 12:37:53 -0500
commit2a0bb1fa906a4d135ed88de4f705c3ab7214e60c (patch)
tree37d207458c999c5789fd6ca3a2c62d6700ed81b7 /routers
parentc6083c335e53a860fd4c500a86dcdda49a16515e (diff)
downloadgitea-2a0bb1fa906a4d135ed88de4f705c3ab7214e60c.tar.gz
gitea-2a0bb1fa906a4d135ed88de4f705c3ab7214e60c.zip
#1575 Limit repo creation
Diffstat (limited to 'routers')
-rw-r--r--routers/admin/users.go1
-rw-r--r--routers/repo/repo.go8
2 files changed, 6 insertions, 3 deletions
diff --git a/routers/admin/users.go b/routers/admin/users.go
index ae17a99cd9..5e6c3a13cc 100644
--- a/routers/admin/users.go
+++ b/routers/admin/users.go
@@ -210,6 +210,7 @@ func EditUserPost(ctx *middleware.Context, form auth.AdminEditUserForm) {
u.Email = form.Email
u.Website = form.Website
u.Location = form.Location
+ u.MaxRepoCreation = form.MaxRepoCreation
u.IsActive = form.Active
u.IsAdmin = form.Admin
u.AllowGitHook = form.AllowGitHook
diff --git a/routers/repo/repo.go b/routers/repo/repo.go
index c70d55a625..3cd06eba9f 100644
--- a/routers/repo/repo.go
+++ b/routers/repo/repo.go
@@ -78,8 +78,10 @@ func Create(ctx *middleware.Context) {
ctx.HTML(200, CREATE)
}
-func handleCreateError(ctx *middleware.Context, err error, name string, tpl base.TplName, form interface{}) {
+func handleCreateError(ctx *middleware.Context, owner *models.User, err error, name string, tpl base.TplName, form interface{}) {
switch {
+ case models.IsErrReachLimitOfRepo(err):
+ ctx.RenderWithErr(ctx.Tr("repo.form.reach_limit_of_creation", owner.RepoCreationNum()), tpl, form)
case models.IsErrRepoAlreadyExist(err):
ctx.Data["Err_RepoName"] = true
ctx.RenderWithErr(ctx.Tr("form.repo_name_been_taken"), tpl, form)
@@ -133,7 +135,7 @@ func CreatePost(ctx *middleware.Context, form auth.CreateRepoForm) {
}
}
- handleCreateError(ctx, err, "CreatePost", CREATE, &form)
+ handleCreateError(ctx, ctxUser, err, "CreatePost", CREATE, &form)
}
func Migrate(ctx *middleware.Context) {
@@ -216,7 +218,7 @@ func MigratePost(ctx *middleware.Context, form auth.MigrateRepoForm) {
return
}
- handleCreateError(ctx, err, "MigratePost", MIGRATE, &form)
+ handleCreateError(ctx, ctxUser, err, "MigratePost", MIGRATE, &form)
}
func Action(ctx *middleware.Context) {