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.

179 lines
6.5 KiB

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