repo_form.go 6.5 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. HttpsUrl string `form:"url" binding:"Required;Url"`
  29. AuthUserName string `form:"auth_username"`
  30. AuthPasswd string `form:"auth_password"`
  31. Uid int64 `form:"uid" binding:"Required"`
  32. RepoName string `form:"repo_name" binding:"Required;AlphaDashDot;MaxSize(100)"`
  33. Mirror bool `form:"mirror"`
  34. Private bool `form:"private"`
  35. Description string `form:"desc" 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. GoGet bool `form:"goget"`
  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 NewWebhookForm struct {
  59. HookTaskType string `form:"hook_type" binding:"Required"`
  60. PayloadUrl string `form:"payload_url" binding:"Required;Url"`
  61. ContentType string `form:"content_type" binding:"Required"`
  62. Secret string `form:"secret"`
  63. PushOnly bool `form:"push_only"`
  64. Active bool `form:"active"`
  65. }
  66. func (f *NewWebhookForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  67. return validate(errs, ctx.Data, f, ctx.Locale)
  68. }
  69. type NewSlackHookForm struct {
  70. HookTaskType string `form:"hook_type" binding:"Required"`
  71. PayloadUrl string `form:"payload_url" binding:"Required`
  72. Channel string `form:"channel" binding:"Required"`
  73. PushOnly bool `form:"push_only"`
  74. Active bool `form:"active"`
  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. IssueName string `form:"title" binding:"Required;MaxSize(255)"`
  87. MilestoneId int64 `form:"milestoneid"`
  88. AssigneeId int64 `form:"assigneeid"`
  89. Labels string `form:"labels"`
  90. Content string `form:"content"`
  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 `form:"title" binding:"Required;MaxSize(50)"`
  103. Content string `form:"content"`
  104. Deadline string `form:"due_date"`
  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. Title string `form:"title" binding:"Required;MaxSize(50)"`
  117. Color string `form:"color" binding:"Required;Size(7)"`
  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. }