repo_form.go 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. "github.com/Unknwon/macaron"
  7. "github.com/macaron-contrib/binding"
  8. )
  9. // _______________________________________ _________.______________________ _______________.___.
  10. // \______ \_ _____/\______ \_____ \ / _____/| \__ ___/\_____ \\______ \__ | |
  11. // | _/| __)_ | ___// | \ \_____ \ | | | | / | \| _// | |
  12. // | | \| \ | | / | \/ \| | | | / | \ | \\____ |
  13. // |____|_ /_______ / |____| \_______ /_______ /|___| |____| \_______ /____|_ // ______|
  14. // \/ \/ \/ \/ \/ \/ \/
  15. type CreateRepoForm struct {
  16. Uid int64 `form:"uid" binding:"Required"`
  17. RepoName string `form:"repo_name" binding:"Required;AlphaDashDot;MaxSize(100)"`
  18. Private bool `form:"private"`
  19. Description string `form:"desc" binding:"MaxSize(255)"`
  20. AutoInit bool `form:"auto_init"`
  21. Gitignore string `form:"gitignore"`
  22. License string `form:"license"`
  23. }
  24. func (f *CreateRepoForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  25. return validate(errs, ctx.Data, f, ctx.Locale)
  26. }
  27. type MigrateRepoForm struct {
  28. CloneAddr string `binding:"Required"`
  29. AuthUsername string
  30. AuthPassword string
  31. Uid int64 `binding:"Required"`
  32. RepoName string `binding:"Required;AlphaDashDot;MaxSize(100)"`
  33. Mirror bool
  34. Private bool
  35. Description string `binding:"MaxSize(255)"`
  36. }
  37. func (f *MigrateRepoForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  38. return validate(errs, ctx.Data, f, ctx.Locale)
  39. }
  40. type RepoSettingForm struct {
  41. RepoName string `form:"repo_name" binding:"Required;AlphaDashDot;MaxSize(100)"`
  42. Description string `form:"desc" binding:"MaxSize(255)"`
  43. Website string `form:"site" binding:"Url;MaxSize(100)"`
  44. Branch string `form:"branch"`
  45. Interval int `form:"interval"`
  46. Private bool `form:"private"`
  47. }
  48. func (f *RepoSettingForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  49. return validate(errs, ctx.Data, f, ctx.Locale)
  50. }
  51. // __ __ ___. .__ .__ __
  52. // / \ / \ ____\_ |__ | |__ | |__ ____ | | __
  53. // \ \/\/ // __ \| __ \| | \| | \ / _ \| |/ /
  54. // \ /\ ___/| \_\ \ Y \ Y ( <_> ) <
  55. // \__/\ / \___ >___ /___| /___| /\____/|__|_ \
  56. // \/ \/ \/ \/ \/ \/
  57. type NewWebhookForm struct {
  58. HookTaskType string `form:"hook_type" binding:"Required"`
  59. PayloadUrl string `form:"payload_url" binding:"Required;Url"`
  60. ContentType string `form:"content_type" binding:"Required"`
  61. Secret string `form:"secret"`
  62. PushOnly bool `form:"push_only"`
  63. Active bool `form:"active"`
  64. }
  65. func (f *NewWebhookForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  66. return validate(errs, ctx.Data, f, ctx.Locale)
  67. }
  68. type NewSlackHookForm struct {
  69. HookTaskType string `form:"hook_type" binding:"Required"`
  70. PayloadUrl string `form:"payload_url" binding:"Required`
  71. Channel string `form:"channel" binding:"Required"`
  72. PushOnly bool `form:"push_only"`
  73. Active bool `form:"active"`
  74. }
  75. func (f *NewSlackHookForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  76. return validate(errs, ctx.Data, f, ctx.Locale)
  77. }
  78. // .___
  79. // | | ______ ________ __ ____
  80. // | |/ ___// ___/ | \_/ __ \
  81. // | |\___ \ \___ \| | /\ ___/
  82. // |___/____ >____ >____/ \___ >
  83. // \/ \/ \/
  84. type CreateIssueForm struct {
  85. Title string `binding:"Required;MaxSize(255)"`
  86. LabelIDs string `form:"label_ids"`
  87. MilestoneID int64
  88. AssigneeID int64
  89. Content string
  90. Attachments []string
  91. }
  92. func (f *CreateIssueForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  93. return validate(errs, ctx.Data, f, ctx.Locale)
  94. }
  95. // _____ .__.__ __
  96. // / \ |__| | ____ _______/ |_ ____ ____ ____
  97. // / \ / \| | | _/ __ \ / ___/\ __\/ _ \ / \_/ __ \
  98. // / Y \ | |_\ ___/ \___ \ | | ( <_> ) | \ ___/
  99. // \____|__ /__|____/\___ >____ > |__| \____/|___| /\___ >
  100. // \/ \/ \/ \/ \/
  101. type CreateMilestoneForm struct {
  102. Title string `binding:"Required;MaxSize(50)"`
  103. Content string
  104. Deadline string
  105. }
  106. func (f *CreateMilestoneForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  107. return validate(errs, ctx.Data, f, ctx.Locale)
  108. }
  109. // .____ ___. .__
  110. // | | _____ \_ |__ ____ | |
  111. // | | \__ \ | __ \_/ __ \| |
  112. // | |___ / __ \| \_\ \ ___/| |__
  113. // |_______ (____ /___ /\___ >____/
  114. // \/ \/ \/ \/
  115. type CreateLabelForm struct {
  116. ID int64
  117. Title string `binding:"Required;MaxSize(50)" locale:"repo.issues.label_name"`
  118. Color string `binding:"Required;Size(7)" locale:"repo.issues.label_color"`
  119. }
  120. func (f *CreateLabelForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  121. return validate(errs, ctx.Data, f, ctx.Locale)
  122. }
  123. // __________ .__
  124. // \______ \ ____ | | ____ _____ ______ ____
  125. // | _// __ \| | _/ __ \\__ \ / ___// __ \
  126. // | | \ ___/| |_\ ___/ / __ \_\___ \\ ___/
  127. // |____|_ /\___ >____/\___ >____ /____ >\___ >
  128. // \/ \/ \/ \/ \/ \/
  129. type NewReleaseForm struct {
  130. TagName string `form:"tag_name" binding:"Required"`
  131. Target string `form:"tag_target" binding:"Required"`
  132. Title string `form:"title" binding:"Required"`
  133. Content string `form:"content" binding:"Required"`
  134. Draft string `form:"draft"`
  135. Prerelease bool `form:"prerelease"`
  136. }
  137. func (f *NewReleaseForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  138. return validate(errs, ctx.Data, f, ctx.Locale)
  139. }
  140. type EditReleaseForm struct {
  141. Title string `form:"title" binding:"Required"`
  142. Content string `form:"content" binding:"Required"`
  143. Draft string `form:"draft"`
  144. Prerelease bool `form:"prerelease"`
  145. }
  146. func (f *EditReleaseForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  147. return validate(errs, ctx.Data, f, ctx.Locale)
  148. }