repo_form.go 6.3 KB

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. IssueName string `form:"title" binding:"Required;MaxSize(255)"`
  86. MilestoneId int64 `form:"milestoneid"`
  87. AssigneeId int64 `form:"assigneeid"`
  88. Labels string `form:"labels"`
  89. Content string `form:"content"`
  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 `form:"title" binding:"Required;MaxSize(50)"`
  102. Content string `form:"content"`
  103. Deadline string `form:"due_date"`
  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. Title string `form:"title" binding:"Required;MaxSize(50)"`
  116. Color string `form:"color" binding:"Required;Size(7)"`
  117. }
  118. func (f *CreateLabelForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  119. return validate(errs, ctx.Data, f, ctx.Locale)
  120. }
  121. // __________ .__
  122. // \______ \ ____ | | ____ _____ ______ ____
  123. // | _// __ \| | _/ __ \\__ \ / ___// __ \
  124. // | | \ ___/| |_\ ___/ / __ \_\___ \\ ___/
  125. // |____|_ /\___ >____/\___ >____ /____ >\___ >
  126. // \/ \/ \/ \/ \/ \/
  127. type NewReleaseForm struct {
  128. TagName string `form:"tag_name" binding:"Required"`
  129. Target string `form:"tag_target" binding:"Required"`
  130. Title string `form:"title" binding:"Required"`
  131. Content string `form:"content" binding:"Required"`
  132. Draft string `form:"draft"`
  133. Prerelease bool `form:"prerelease"`
  134. }
  135. func (f *NewReleaseForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  136. return validate(errs, ctx.Data, f, ctx.Locale)
  137. }
  138. type EditReleaseForm struct {
  139. Title string `form:"title" binding:"Required"`
  140. Content string `form:"content" binding:"Required"`
  141. Draft string `form:"draft"`
  142. Prerelease bool `form:"prerelease"`
  143. }
  144. func (f *EditReleaseForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  145. return validate(errs, ctx.Data, f, ctx.Locale)
  146. }