summaryrefslogtreecommitdiffstats
path: root/routers/repo/repo.go
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-03-15 10:52:14 -0400
committerUnknown <joe2010xtmf@163.com>2014-03-15 10:52:14 -0400
commitb43cfc5b39c0aeec04b1810f01e57ece96abdd7e (patch)
treeb97e7afc172b8fdca001ba4715d7611fa66272cb /routers/repo/repo.go
parent12b98bb58a1f14e5ab71acd13dfe99c494e93898 (diff)
downloadgitea-b43cfc5b39c0aeec04b1810f01e57ece96abdd7e.tar.gz
gitea-b43cfc5b39c0aeec04b1810f01e57ece96abdd7e.zip
Clean code
Diffstat (limited to 'routers/repo/repo.go')
-rw-r--r--routers/repo/repo.go12
1 files changed, 3 insertions, 9 deletions
diff --git a/routers/repo/repo.go b/routers/repo/repo.go
index 710e5a21d6..23f8ea107c 100644
--- a/routers/repo/repo.go
+++ b/routers/repo/repo.go
@@ -20,7 +20,7 @@ func Create(ctx *middleware.Context, form auth.CreateRepoForm) {
return
}
- if hasErr, ok := ctx.Data["HasError"]; ok && hasErr.(bool) {
+ if ctx.HasError() {
ctx.Render.HTML(200, "repo/create", ctx.Data)
return
}
@@ -30,10 +30,7 @@ func Create(ctx *middleware.Context, form auth.CreateRepoForm) {
user, err := models.GetUserById(form.UserId)
if err != nil {
if err.Error() == models.ErrUserNotExist.Error() {
- ctx.Data["HasError"] = true
- ctx.Data["ErrorMsg"] = "User does not exist"
- auth.AssignForm(form, ctx.Data)
- ctx.Render.HTML(200, "repo/create", ctx.Data)
+ ctx.RenderWithErr("User does not exist", "repo/create", &form)
return
}
}
@@ -48,10 +45,7 @@ func Create(ctx *middleware.Context, form auth.CreateRepoForm) {
}
if err.Error() == models.ErrRepoAlreadyExist.Error() {
- ctx.Data["HasError"] = true
- ctx.Data["ErrorMsg"] = "Repository name has already been used"
- auth.AssignForm(form, ctx.Data)
- ctx.Render.HTML(200, "repo/create", ctx.Data)
+ ctx.RenderWithErr("Repository name has already been used", "repo/create", &form)
return
}