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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. }
  91. func (f *CreateIssueForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  92. return validate(errs, ctx.Data, f, ctx.Locale)
  93. }
  94. // _____ .__.__ __
  95. // / \ |__| | ____ _______/ |_ ____ ____ ____
  96. // / \ / \| | | _/ __ \ / ___/\ __\/ _ \ / \_/ __ \
  97. // / Y \ | |_\ ___/ \___ \ | | ( <_> ) | \ ___/
  98. // \____|__ /__|____/\___ >____ > |__| \____/|___| /\___ >
  99. // \/ \/ \/ \/ \/
  100. type CreateMilestoneForm struct {
  101. Title string `binding:"Required;MaxSize(50)"`
  102. Content string
  103. Deadline string
  104. }
  105. func (f *CreateMilestoneForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  106. return validate(errs, ctx.Data, f, ctx.Locale)
  107. }
  108. // .____ ___. .__
  109. // | | _____ \_ |__ ____ | |
  110. // | | \__ \ | __ \_/ __ \| |
  111. // | |___ / __ \| \_\ \ ___/| |__
  112. // |_______ (____ /___ /\___ >____/
  113. // \/ \/ \/ \/
  114. type CreateLabelForm struct {
  115. ID int64
  116. Title string `binding:"Required;MaxSize(50)" locale:"repo.issues.label_name"`
  117. Color string `binding:"Required;Size(7)" locale:"repo.issues.label_color"`
  118. }
  119. func (f *CreateLabelForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  120. return validate(errs, ctx.Data, f, ctx.Locale)
  121. }
  122. // __________ .__
  123. // \______ \ ____ | | ____ _____ ______ ____
  124. // | _// __ \| | _/ __ \\__ \ / ___// __ \
  125. // | | \ ___/| |_\ ___/ / __ \_\___ \\ ___/
  126. // |____|_ /\___ >____/\___ >____ /____ >\___ >
  127. // \/ \/ \/ \/ \/ \/
  128. type NewReleaseForm struct {
  129. TagName string `form:"tag_name" binding:"Required"`
  130. Target string `form:"tag_target" binding:"Required"`
  131. Title string `form:"title" binding:"Required"`
  132. Content string `form:"content" binding:"Required"`
  133. Draft string `form:"draft"`
  134. Prerelease bool `form:"prerelease"`
  135. }
  136. func (f *NewReleaseForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  137. return validate(errs, ctx.Data, f, ctx.Locale)
  138. }
  139. type EditReleaseForm struct {
  140. Title string `form:"title" binding:"Required"`
  141. Content string `form:"content" binding:"Required"`
  142. Draft string `form:"draft"`
  143. Prerelease bool `form:"prerelease"`
  144. }
  145. func (f *EditReleaseForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  146. return validate(errs, ctx.Data, f, ctx.Locale)
  147. }