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.

repo_form.go 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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;AlphaDash;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. Url string `form:"url" binding:"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" binding:"Required;AlphaDash;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:"name" binding:"Required;AlphaDash;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. Url string `form:"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, l i18n.Locale) {
  67. validate(errs, ctx.Data, f, l)
  68. }
  69. // .___
  70. // | | ______ ________ __ ____
  71. // | |/ ___// ___/ | \_/ __ \
  72. // | |\___ \ \___ \| | /\ ___/
  73. // |___/____ >____ >____/ \___ >
  74. // \/ \/ \/
  75. type CreateIssueForm struct {
  76. IssueName string `form:"title" binding:"Required;MaxSize(50)"`
  77. MilestoneId int64 `form:"milestoneid"`
  78. AssigneeId int64 `form:"assigneeid"`
  79. Labels string `form:"labels"`
  80. Content string `form:"content"`
  81. }
  82. func (f *CreateIssueForm) Validate(ctx *macaron.Context, errs *binding.Errors, l i18n.Locale) {
  83. validate(errs, ctx.Data, f, l)
  84. }
  85. // _____ .__.__ __
  86. // / \ |__| | ____ _______/ |_ ____ ____ ____
  87. // / \ / \| | | _/ __ \ / ___/\ __\/ _ \ / \_/ __ \
  88. // / Y \ | |_\ ___/ \___ \ | | ( <_> ) | \ ___/
  89. // \____|__ /__|____/\___ >____ > |__| \____/|___| /\___ >
  90. // \/ \/ \/ \/ \/
  91. type CreateMilestoneForm struct {
  92. Title string `form:"title" binding:"Required;MaxSize(50)"`
  93. Content string `form:"content"`
  94. Deadline string `form:"due_date"`
  95. }
  96. func (f *CreateMilestoneForm) Validate(ctx *macaron.Context, errs *binding.Errors, l i18n.Locale) {
  97. validate(errs, ctx.Data, f, l)
  98. }
  99. // .____ ___. .__
  100. // | | _____ \_ |__ ____ | |
  101. // | | \__ \ | __ \_/ __ \| |
  102. // | |___ / __ \| \_\ \ ___/| |__
  103. // |_______ (____ /___ /\___ >____/
  104. // \/ \/ \/ \/
  105. type CreateLabelForm struct {
  106. Title string `form:"title" binding:"Required;MaxSize(50)"`
  107. Color string `form:"color" binding:"Required;Size(7)"`
  108. }
  109. func (f *CreateLabelForm) Validate(ctx *macaron.Context, errs *binding.Errors, l i18n.Locale) {
  110. validate(errs, ctx.Data, f, l)
  111. }
  112. // __________ .__
  113. // \______ \ ____ | | ____ _____ ______ ____
  114. // | _// __ \| | _/ __ \\__ \ / ___// __ \
  115. // | | \ ___/| |_\ ___/ / __ \_\___ \\ ___/
  116. // |____|_ /\___ >____/\___ >____ /____ >\___ >
  117. // \/ \/ \/ \/ \/ \/
  118. type NewReleaseForm struct {
  119. TagName string `form:"tag_name" binding:"Required"`
  120. Target string `form:"tag_target" binding:"Required"`
  121. Title string `form:"title" binding:"Required"`
  122. Content string `form:"content" binding:"Required"`
  123. Draft string `form:"draft"`
  124. Prerelease bool `form:"prerelease"`
  125. }
  126. func (f *NewReleaseForm) Validate(ctx *macaron.Context, errs *binding.Errors, l i18n.Locale) {
  127. validate(errs, ctx.Data, f, l)
  128. }
  129. type EditReleaseForm struct {
  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 *EditReleaseForm) Validate(ctx *macaron.Context, errs *binding.Errors, l i18n.Locale) {
  137. validate(errs, ctx.Data, f, l)
  138. }