repo_form.go 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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 `binding:"Required"`
  17. RepoName string `binding:"Required;AlphaDashDot;MaxSize(100)"`
  18. Private bool
  19. Description string `binding:"MaxSize(255)"`
  20. AutoInit bool
  21. Gitignores string
  22. License string
  23. Readme string
  24. }
  25. func (f *CreateRepoForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  26. return validate(errs, ctx.Data, f, ctx.Locale)
  27. }
  28. type MigrateRepoForm struct {
  29. CloneAddr string `binding:"Required"`
  30. AuthUsername string
  31. AuthPassword string
  32. Mirror bool
  33. Uid int64 `binding:"Required"`
  34. RepoName string `binding:"Required;AlphaDashDot;MaxSize(100)"`
  35. Private bool
  36. Description string `binding:"MaxSize(255)"`
  37. }
  38. func (f *MigrateRepoForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  39. return validate(errs, ctx.Data, f, ctx.Locale)
  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. }
  49. func (f *RepoSettingForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  50. return validate(errs, ctx.Data, f, ctx.Locale)
  51. }
  52. // __ __ ___. .__ .__ __
  53. // / \ / \ ____\_ |__ | |__ | |__ ____ | | __
  54. // \ \/\/ // __ \| __ \| | \| | \ / _ \| |/ /
  55. // \ /\ ___/| \_\ \ Y \ Y ( <_> ) <
  56. // \__/\ / \___ >___ /___| /___| /\____/|__|_ \
  57. // \/ \/ \/ \/ \/ \/
  58. type WebhookForm struct {
  59. PushOnly bool
  60. Active bool
  61. }
  62. type NewWebhookForm struct {
  63. PayloadURL string `binding:"Required;Url"`
  64. ContentType int `binding:"Required"`
  65. Secret string
  66. WebhookForm
  67. }
  68. func (f *NewWebhookForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  69. return validate(errs, ctx.Data, f, ctx.Locale)
  70. }
  71. type NewSlackHookForm struct {
  72. PayloadURL string `binding:"Required`
  73. Channel string `binding:"Required"`
  74. WebhookForm
  75. }
  76. func (f *NewSlackHookForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  77. return validate(errs, ctx.Data, f, ctx.Locale)
  78. }
  79. // .___
  80. // | | ______ ________ __ ____
  81. // | |/ ___// ___/ | \_/ __ \
  82. // | |\___ \ \___ \| | /\ ___/
  83. // |___/____ >____ >____/ \___ >
  84. // \/ \/ \/
  85. type CreateIssueForm struct {
  86. Title string `binding:"Required;MaxSize(255)"`
  87. LabelIDs string `form:"label_ids"`
  88. MilestoneID int64
  89. AssigneeID int64
  90. Content string
  91. Attachments []string
  92. }
  93. func (f *CreateIssueForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  94. return validate(errs, ctx.Data, f, ctx.Locale)
  95. }
  96. type CreateCommentForm struct {
  97. Content string
  98. Status string `binding:"OmitEmpty;In(reopen,close)"`
  99. Attachments []string
  100. }
  101. func (f *CreateCommentForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  102. return validate(errs, ctx.Data, f, ctx.Locale)
  103. }
  104. // _____ .__.__ __
  105. // / \ |__| | ____ _______/ |_ ____ ____ ____
  106. // / \ / \| | | _/ __ \ / ___/\ __\/ _ \ / \_/ __ \
  107. // / Y \ | |_\ ___/ \___ \ | | ( <_> ) | \ ___/
  108. // \____|__ /__|____/\___ >____ > |__| \____/|___| /\___ >
  109. // \/ \/ \/ \/ \/
  110. type CreateMilestoneForm struct {
  111. Title string `binding:"Required;MaxSize(50)"`
  112. Content string
  113. Deadline string
  114. }
  115. func (f *CreateMilestoneForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  116. return validate(errs, ctx.Data, f, ctx.Locale)
  117. }
  118. // .____ ___. .__
  119. // | | _____ \_ |__ ____ | |
  120. // | | \__ \ | __ \_/ __ \| |
  121. // | |___ / __ \| \_\ \ ___/| |__
  122. // |_______ (____ /___ /\___ >____/
  123. // \/ \/ \/ \/
  124. type CreateLabelForm struct {
  125. ID int64
  126. Title string `binding:"Required;MaxSize(50)" locale:"repo.issues.label_name"`
  127. Color string `binding:"Required;Size(7)" locale:"repo.issues.label_color"`
  128. }
  129. func (f *CreateLabelForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  130. return validate(errs, ctx.Data, f, ctx.Locale)
  131. }
  132. // __________ .__
  133. // \______ \ ____ | | ____ _____ ______ ____
  134. // | _// __ \| | _/ __ \\__ \ / ___// __ \
  135. // | | \ ___/| |_\ ___/ / __ \_\___ \\ ___/
  136. // |____|_ /\___ >____/\___ >____ /____ >\___ >
  137. // \/ \/ \/ \/ \/ \/
  138. type NewReleaseForm struct {
  139. TagName string `form:"tag_name" binding:"Required"`
  140. Target string `form:"tag_target" binding:"Required"`
  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 *NewReleaseForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  147. return validate(errs, ctx.Data, f, ctx.Locale)
  148. }
  149. type EditReleaseForm struct {
  150. Title string `form:"title" binding:"Required"`
  151. Content string `form:"content" binding:"Required"`
  152. Draft string `form:"draft"`
  153. Prerelease bool `form:"prerelease"`
  154. }
  155. func (f *EditReleaseForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  156. return validate(errs, ctx.Data, f, ctx.Locale)
  157. }