You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
3.2 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package auth
  5. import (
  6. "net/http"
  7. "reflect"
  8. "github.com/go-martini/martini"
  9. "github.com/gogits/gogs/modules/base"
  10. "github.com/gogits/gogs/modules/middleware/binding"
  11. )
  12. type CreateRepoForm struct {
  13. RepoName string `form:"repo" binding:"Required;AlphaDash;MaxSize(100)"`
  14. Private bool `form:"private"`
  15. Description string `form:"desc" binding:"MaxSize(100)"`
  16. Language string `form:"language"`
  17. License string `form:"license"`
  18. InitReadme bool `form:"initReadme"`
  19. }
  20. func (f *CreateRepoForm) Name(field string) string {
  21. names := map[string]string{
  22. "RepoName": "Repository name",
  23. "Description": "Description",
  24. }
  25. return names[field]
  26. }
  27. func (f *CreateRepoForm) Validate(errors *binding.Errors, req *http.Request, context martini.Context) {
  28. data := context.Get(reflect.TypeOf(base.TmplData{})).Interface().(base.TmplData)
  29. validate(errors, data, f)
  30. }
  31. type MigrateRepoForm struct {
  32. Url string `form:"url" binding:"Url"`
  33. AuthUserName string `form:"auth_username"`
  34. AuthPasswd string `form:"auth_password"`
  35. RepoName string `form:"repo" binding:"Required;AlphaDash;MaxSize(100)"`
  36. Mirror bool `form:"mirror"`
  37. Private bool `form:"private"`
  38. Description string `form:"desc" binding:"MaxSize(100)"`
  39. }
  40. func (f *MigrateRepoForm) Name(field string) string {
  41. names := map[string]string{
  42. "Url": "Migration URL",
  43. "RepoName": "Repository name",
  44. "Description": "Description",
  45. }
  46. return names[field]
  47. }
  48. func (f *MigrateRepoForm) Validate(errors *binding.Errors, req *http.Request, context martini.Context) {
  49. data := context.Get(reflect.TypeOf(base.TmplData{})).Interface().(base.TmplData)
  50. validate(errors, data, f)
  51. }
  52. type RepoSettingForm struct {
  53. RepoName string `form:"name" binding:"Required;AlphaDash;MaxSize(100)"`
  54. Description string `form:"desc" binding:"MaxSize(100)"`
  55. Website string `form:"url" binding:"Url;MaxSize(100)"`
  56. Branch string `form:"branch"`
  57. Interval int `form:"interval"`
  58. Private bool `form:"private"`
  59. GoGet bool `form:"goget"`
  60. }
  61. func (f *RepoSettingForm) Name(field string) string {
  62. names := map[string]string{
  63. "RepoName": "Repository name",
  64. "Description": "Description",
  65. "Website": "Website address",
  66. }
  67. return names[field]
  68. }
  69. func (f *RepoSettingForm) Validate(errors *binding.Errors, req *http.Request, context martini.Context) {
  70. data := context.Get(reflect.TypeOf(base.TmplData{})).Interface().(base.TmplData)
  71. validate(errors, data, f)
  72. }
  73. type NewWebhookForm struct {
  74. Url string `form:"url" binding:"Required;Url"`
  75. ContentType string `form:"content_type" binding:"Required"`
  76. Secret string `form:"secret""`
  77. PushOnly bool `form:"push_only"`
  78. Active bool `form:"active"`
  79. }
  80. func (f *NewWebhookForm) Name(field string) string {
  81. names := map[string]string{
  82. "Url": "Payload URL",
  83. "ContentType": "Content type",
  84. }
  85. return names[field]
  86. }
  87. func (f *NewWebhookForm) Validate(errors *binding.Errors, req *http.Request, context martini.Context) {
  88. data := context.Get(reflect.TypeOf(base.TmplData{})).Interface().(base.TmplData)
  89. validate(errors, data, f)
  90. }