diff options
author | Unknown <joe2010xtmf@163.com> | 2014-04-14 01:57:25 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-04-14 01:57:25 -0400 |
commit | f644cefa865c04b440902695ba90114b224c640d (patch) | |
tree | 0046427683c47bbc0487d0d053ee643ffef902c8 /modules/auth | |
parent | 190b83e05eb1ade979c0e17314ab892832d62e5b (diff) | |
download | gitea-f644cefa865c04b440902695ba90114b224c640d.tar.gz gitea-f644cefa865c04b440902695ba90114b224c640d.zip |
Finish release
Diffstat (limited to 'modules/auth')
-rw-r--r-- | modules/auth/release.go | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/modules/auth/release.go b/modules/auth/release.go new file mode 100644 index 0000000000..a29028e0e4 --- /dev/null +++ b/modules/auth/release.go @@ -0,0 +1,50 @@ +// Copyright 2014 The Gogs Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package auth + +import ( + "net/http" + "reflect" + + "github.com/go-martini/martini" + + "github.com/gogits/gogs/modules/base" + "github.com/gogits/gogs/modules/log" +) + +type NewReleaseForm struct { + TagName string `form:"tag_name" binding:"Required"` + Title string `form:"title" binding:"Required"` + Content string `form:"content" binding:"Required"` + Prerelease bool `form:"prerelease"` +} + +func (f *NewReleaseForm) Name(field string) string { + names := map[string]string{ + "TagName": "Tag name", + "Title": "Release title", + "Content": "Release content", + } + return names[field] +} + +func (f *NewReleaseForm) Validate(errors *base.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("NewReleaseForm.Validate: %v", err) + } + return + } + + validate(errors, data, f) +} |