diff options
author | Unknown <joe2010xtmf@163.com> | 2014-05-05 19:58:13 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-05-05 19:58:13 -0400 |
commit | 6e3dba2cc559275b5287673957ec855e61b4163a (patch) | |
tree | e7188a38aad06b17663aa48b03b523ab24329c58 /modules/auth/repo.go | |
parent | bbdfe2576966210cfffc830bfbe3731bcf653b3b (diff) | |
download | gitea-6e3dba2cc559275b5287673957ec855e61b4163a.tar.gz gitea-6e3dba2cc559275b5287673957ec855e61b4163a.zip |
Clean repo code
Diffstat (limited to 'modules/auth/repo.go')
-rw-r--r-- | modules/auth/repo.go | 51 |
1 files changed, 23 insertions, 28 deletions
diff --git a/modules/auth/repo.go b/modules/auth/repo.go index e61e8202ff..54fa99c83d 100644 --- a/modules/auth/repo.go +++ b/modules/auth/repo.go @@ -11,12 +11,11 @@ import ( "github.com/go-martini/martini" "github.com/gogits/gogs/modules/base" - "github.com/gogits/gogs/modules/log" "github.com/gogits/gogs/modules/middleware/binding" ) type CreateRepoForm struct { - RepoName string `form:"repo" binding:"Required;AlphaDash"` + RepoName string `form:"repo" binding:"Required;AlphaDash;MaxSize(100)"` Private bool `form:"private"` Description string `form:"desc" binding:"MaxSize(100)"` Language string `form:"language"` @@ -33,21 +32,7 @@ func (f *CreateRepoForm) Name(field string) string { } func (f *CreateRepoForm) Validate(errors *binding.BindingErrors, req *http.Request, context martini.Context) { - if req.Method == "GET" || errors.Count() == 0 { - return - } - data := context.Get(reflect.TypeOf(base.TmplData{})).Interface().(base.TmplData) - data["HasError"] = true - AssignForm(f, data) - - if len(errors.Overall) > 0 { - for _, err := range errors.Overall { - log.Error("CreateRepoForm.Validate: %v", err) - } - return - } - validate(errors, data, f) } @@ -55,7 +40,7 @@ type MigrateRepoForm struct { Url string `form:"url" binding:"Url"` AuthUserName string `form:"auth_username"` AuthPasswd string `form:"auth_password"` - RepoName string `form:"repo" binding:"Required;AlphaDash"` + RepoName string `form:"repo" binding:"Required;AlphaDash;MaxSize(100)"` Mirror bool `form:"mirror"` Private bool `form:"private"` Description string `form:"desc" binding:"MaxSize(100)"` @@ -71,20 +56,30 @@ func (f *MigrateRepoForm) Name(field string) string { } func (f *MigrateRepoForm) Validate(errors *binding.BindingErrors, req *http.Request, context martini.Context) { - if req.Method == "GET" || errors.Count() == 0 { - return - } - data := context.Get(reflect.TypeOf(base.TmplData{})).Interface().(base.TmplData) - data["HasError"] = true - AssignForm(f, data) + validate(errors, data, f) +} - if len(errors.Overall) > 0 { - for _, err := range errors.Overall { - log.Error("MigrateRepoForm.Validate: %v", err) - } - return +type RepoSettingForm struct { + RepoName string `form:"name" binding:"Required;AlphaDash;MaxSize(100)"` + Description string `form:"desc" binding:"MaxSize(100)"` + Website string `form:"url" binding:"Url;MaxSize(100)"` + Branch string `form:"branch"` + Interval int `form:"interval"` + Private bool `form:"private"` + GoGet bool `form:"goget"` +} + +func (f *RepoSettingForm) Name(field string) string { + names := map[string]string{ + "RepoName": "Repository name", + "Description": "Description", + "Website": "Website address", } + return names[field] +} +func (f *RepoSettingForm) Validate(errors *binding.BindingErrors, req *http.Request, context martini.Context) { + data := context.Get(reflect.TypeOf(base.TmplData{})).Interface().(base.TmplData) validate(errors, data, f) } |