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 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Copyright 2017 The Gitea Authors. All rights reserved.
  3. // Use of this source code is governed by a MIT-style
  4. // license that can be found in the LICENSE file.
  5. package auth
  6. import (
  7. "net/url"
  8. "strings"
  9. "code.gitea.io/gitea/models"
  10. "code.gitea.io/gitea/modules/setting"
  11. "code.gitea.io/gitea/routers/utils"
  12. "github.com/Unknwon/com"
  13. "github.com/go-macaron/binding"
  14. macaron "gopkg.in/macaron.v1"
  15. )
  16. // _______________________________________ _________.______________________ _______________.___.
  17. // \______ \_ _____/\______ \_____ \ / _____/| \__ ___/\_____ \\______ \__ | |
  18. // | _/| __)_ | ___// | \ \_____ \ | | | | / | \| _// | |
  19. // | | \| \ | | / | \/ \| | | | / | \ | \\____ |
  20. // |____|_ /_______ / |____| \_______ /_______ /|___| |____| \_______ /____|_ // ______|
  21. // \/ \/ \/ \/ \/ \/ \/
  22. // CreateRepoForm form for creating repository
  23. type CreateRepoForm struct {
  24. UID int64 `binding:"Required"`
  25. RepoName string `binding:"Required;AlphaDashDot;MaxSize(100)"`
  26. Private bool
  27. Description string `binding:"MaxSize(255)"`
  28. AutoInit bool
  29. Gitignores string
  30. License string
  31. Readme string
  32. }
  33. // Validate validates the fields
  34. func (f *CreateRepoForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  35. return validate(errs, ctx.Data, f, ctx.Locale)
  36. }
  37. // MigrateRepoForm form for migrating repository
  38. type MigrateRepoForm struct {
  39. // required: true
  40. CloneAddr string `json:"clone_addr" binding:"Required"`
  41. AuthUsername string `json:"auth_username"`
  42. AuthPassword string `json:"auth_password"`
  43. // required: true
  44. UID int64 `json:"uid" binding:"Required"`
  45. // required: true
  46. RepoName string `json:"repo_name" binding:"Required;AlphaDashDot;MaxSize(100)"`
  47. Mirror bool `json:"mirror"`
  48. Private bool `json:"private"`
  49. Description string `json:"description" binding:"MaxSize(255)"`
  50. }
  51. // Validate validates the fields
  52. func (f *MigrateRepoForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  53. return validate(errs, ctx.Data, f, ctx.Locale)
  54. }
  55. // ParseRemoteAddr checks if given remote address is valid,
  56. // and returns composed URL with needed username and password.
  57. // It also checks if given user has permission when remote address
  58. // is actually a local path.
  59. func (f MigrateRepoForm) ParseRemoteAddr(user *models.User) (string, error) {
  60. remoteAddr := strings.TrimSpace(f.CloneAddr)
  61. // Remote address can be HTTP/HTTPS/Git URL or local path.
  62. if strings.HasPrefix(remoteAddr, "http://") ||
  63. strings.HasPrefix(remoteAddr, "https://") ||
  64. strings.HasPrefix(remoteAddr, "git://") {
  65. u, err := url.Parse(remoteAddr)
  66. if err != nil {
  67. return "", models.ErrInvalidCloneAddr{IsURLError: true}
  68. }
  69. if len(f.AuthUsername)+len(f.AuthPassword) > 0 {
  70. u.User = url.UserPassword(f.AuthUsername, f.AuthPassword)
  71. }
  72. remoteAddr = u.String()
  73. } else if !user.CanImportLocal() {
  74. return "", models.ErrInvalidCloneAddr{IsPermissionDenied: true}
  75. } else if !com.IsDir(remoteAddr) {
  76. return "", models.ErrInvalidCloneAddr{IsInvalidPath: true}
  77. }
  78. return remoteAddr, nil
  79. }
  80. // RepoSettingForm form for changing repository settings
  81. type RepoSettingForm struct {
  82. RepoName string `binding:"Required;AlphaDashDot;MaxSize(100)"`
  83. Description string `binding:"MaxSize(255)"`
  84. Website string `binding:"ValidUrl;MaxSize(255)"`
  85. Interval string
  86. MirrorAddress string
  87. Private bool
  88. EnablePrune bool
  89. // Advanced settings
  90. EnableWiki bool
  91. EnableExternalWiki bool
  92. ExternalWikiURL string
  93. EnableIssues bool
  94. EnableExternalTracker bool
  95. ExternalTrackerURL string
  96. TrackerURLFormat string
  97. TrackerIssueStyle string
  98. EnablePulls bool
  99. PullsIgnoreWhitespace bool
  100. PullsAllowMerge bool
  101. PullsAllowRebase bool
  102. PullsAllowRebaseMerge bool
  103. PullsAllowSquash bool
  104. EnableTimetracker bool
  105. AllowOnlyContributorsToTrackTime bool
  106. EnableIssueDependencies bool
  107. IsArchived bool
  108. // Admin settings
  109. EnableHealthCheck bool
  110. EnableCloseIssuesViaCommitInAnyBranch bool
  111. }
  112. // Validate validates the fields
  113. func (f *RepoSettingForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  114. return validate(errs, ctx.Data, f, ctx.Locale)
  115. }
  116. // __________ .__
  117. // \______ \____________ ____ ____ | |__
  118. // | | _/\_ __ \__ \ / \_/ ___\| | \
  119. // | | \ | | \// __ \| | \ \___| Y \
  120. // |______ / |__| (____ /___| /\___ >___| /
  121. // \/ \/ \/ \/ \/
  122. // ProtectBranchForm form for changing protected branch settings
  123. type ProtectBranchForm struct {
  124. Protected bool
  125. EnableWhitelist bool
  126. WhitelistUsers string
  127. WhitelistTeams string
  128. EnableMergeWhitelist bool
  129. MergeWhitelistUsers string
  130. MergeWhitelistTeams string
  131. RequiredApprovals int64
  132. ApprovalsWhitelistUsers string
  133. ApprovalsWhitelistTeams string
  134. }
  135. // Validate validates the fields
  136. func (f *ProtectBranchForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  137. return validate(errs, ctx.Data, f, ctx.Locale)
  138. }
  139. // __ __ ___. .__ .__ __
  140. // / \ / \ ____\_ |__ | |__ | |__ ____ | | __
  141. // \ \/\/ // __ \| __ \| | \| | \ / _ \| |/ /
  142. // \ /\ ___/| \_\ \ Y \ Y ( <_> ) <
  143. // \__/\ / \___ >___ /___| /___| /\____/|__|_ \
  144. // \/ \/ \/ \/ \/ \/
  145. // WebhookForm form for changing web hook
  146. type WebhookForm struct {
  147. Events string
  148. Create bool
  149. Delete bool
  150. Fork bool
  151. Issues bool
  152. IssueComment bool
  153. Release bool
  154. Push bool
  155. PullRequest bool
  156. Repository bool
  157. Active bool
  158. }
  159. // PushOnly if the hook will be triggered when push
  160. func (f WebhookForm) PushOnly() bool {
  161. return f.Events == "push_only"
  162. }
  163. // SendEverything if the hook will be triggered any event
  164. func (f WebhookForm) SendEverything() bool {
  165. return f.Events == "send_everything"
  166. }
  167. // ChooseEvents if the hook will be triggered choose events
  168. func (f WebhookForm) ChooseEvents() bool {
  169. return f.Events == "choose_events"
  170. }
  171. // NewWebhookForm form for creating web hook
  172. type NewWebhookForm struct {
  173. PayloadURL string `binding:"Required;ValidUrl"`
  174. ContentType int `binding:"Required"`
  175. Secret string
  176. WebhookForm
  177. }
  178. // Validate validates the fields
  179. func (f *NewWebhookForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  180. return validate(errs, ctx.Data, f, ctx.Locale)
  181. }
  182. // NewGogshookForm form for creating gogs hook
  183. type NewGogshookForm struct {
  184. PayloadURL string `binding:"Required;ValidUrl"`
  185. ContentType int `binding:"Required"`
  186. Secret string
  187. WebhookForm
  188. }
  189. // Validate validates the fields
  190. func (f *NewGogshookForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  191. return validate(errs, ctx.Data, f, ctx.Locale)
  192. }
  193. // NewSlackHookForm form for creating slack hook
  194. type NewSlackHookForm struct {
  195. PayloadURL string `binding:"Required;ValidUrl"`
  196. Channel string `binding:"Required"`
  197. Username string
  198. IconURL string
  199. Color string
  200. WebhookForm
  201. }
  202. // Validate validates the fields
  203. func (f *NewSlackHookForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  204. return validate(errs, ctx.Data, f, ctx.Locale)
  205. }
  206. // HasInvalidChannel validates the channel name is in the right format
  207. func (f NewSlackHookForm) HasInvalidChannel() bool {
  208. return !utils.IsValidSlackChannel(f.Channel)
  209. }
  210. // NewDiscordHookForm form for creating discord hook
  211. type NewDiscordHookForm struct {
  212. PayloadURL string `binding:"Required;ValidUrl"`
  213. Username string
  214. IconURL string
  215. WebhookForm
  216. }
  217. // Validate validates the fields
  218. func (f *NewDiscordHookForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  219. return validate(errs, ctx.Data, f, ctx.Locale)
  220. }
  221. // NewDingtalkHookForm form for creating dingtalk hook
  222. type NewDingtalkHookForm struct {
  223. PayloadURL string `binding:"Required;ValidUrl"`
  224. WebhookForm
  225. }
  226. // Validate validates the fields
  227. func (f *NewDingtalkHookForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  228. return validate(errs, ctx.Data, f, ctx.Locale)
  229. }
  230. // .___
  231. // | | ______ ________ __ ____
  232. // | |/ ___// ___/ | \_/ __ \
  233. // | |\___ \ \___ \| | /\ ___/
  234. // |___/____ >____ >____/ \___ >
  235. // \/ \/ \/
  236. // CreateIssueForm form for creating issue
  237. type CreateIssueForm struct {
  238. Title string `binding:"Required;MaxSize(255)"`
  239. LabelIDs string `form:"label_ids"`
  240. AssigneeIDs string `form:"assignee_ids"`
  241. Ref string `form:"ref"`
  242. MilestoneID int64
  243. AssigneeID int64
  244. Content string
  245. Files []string
  246. }
  247. // Validate validates the fields
  248. func (f *CreateIssueForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  249. return validate(errs, ctx.Data, f, ctx.Locale)
  250. }
  251. // CreateCommentForm form for creating comment
  252. type CreateCommentForm struct {
  253. Content string
  254. Status string `binding:"OmitEmpty;In(reopen,close)"`
  255. Files []string
  256. }
  257. // Validate validates the fields
  258. func (f *CreateCommentForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  259. return validate(errs, ctx.Data, f, ctx.Locale)
  260. }
  261. // ReactionForm form for adding and removing reaction
  262. type ReactionForm struct {
  263. Content string `binding:"Required;In(+1,-1,laugh,confused,heart,hooray)"`
  264. }
  265. // Validate validates the fields
  266. func (f *ReactionForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  267. return validate(errs, ctx.Data, f, ctx.Locale)
  268. }
  269. // IssueLockForm form for locking an issue
  270. type IssueLockForm struct {
  271. Reason string `binding:"Required"`
  272. }
  273. // Validate validates the fields
  274. func (i *IssueLockForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  275. return validate(errs, ctx.Data, i, ctx.Locale)
  276. }
  277. // HasValidReason checks to make sure that the reason submitted in
  278. // the form matches any of the values in the config
  279. func (i IssueLockForm) HasValidReason() bool {
  280. if strings.TrimSpace(i.Reason) == "" {
  281. return true
  282. }
  283. for _, v := range setting.Repository.Issue.LockReasons {
  284. if v == i.Reason {
  285. return true
  286. }
  287. }
  288. return false
  289. }
  290. // _____ .__.__ __
  291. // / \ |__| | ____ _______/ |_ ____ ____ ____
  292. // / \ / \| | | _/ __ \ / ___/\ __\/ _ \ / \_/ __ \
  293. // / Y \ | |_\ ___/ \___ \ | | ( <_> ) | \ ___/
  294. // \____|__ /__|____/\___ >____ > |__| \____/|___| /\___ >
  295. // \/ \/ \/ \/ \/
  296. // CreateMilestoneForm form for creating milestone
  297. type CreateMilestoneForm struct {
  298. Title string `binding:"Required;MaxSize(50)"`
  299. Content string
  300. Deadline string
  301. }
  302. // Validate validates the fields
  303. func (f *CreateMilestoneForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  304. return validate(errs, ctx.Data, f, ctx.Locale)
  305. }
  306. // .____ ___. .__
  307. // | | _____ \_ |__ ____ | |
  308. // | | \__ \ | __ \_/ __ \| |
  309. // | |___ / __ \| \_\ \ ___/| |__
  310. // |_______ (____ /___ /\___ >____/
  311. // \/ \/ \/ \/
  312. // CreateLabelForm form for creating label
  313. type CreateLabelForm struct {
  314. ID int64
  315. Title string `binding:"Required;MaxSize(50)" locale:"repo.issues.label_title"`
  316. Description string `binding:"MaxSize(200)" locale:"repo.issues.label_description"`
  317. Color string `binding:"Required;Size(7)" locale:"repo.issues.label_color"`
  318. }
  319. // Validate validates the fields
  320. func (f *CreateLabelForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  321. return validate(errs, ctx.Data, f, ctx.Locale)
  322. }
  323. // InitializeLabelsForm form for initializing labels
  324. type InitializeLabelsForm struct {
  325. TemplateName string `binding:"Required"`
  326. }
  327. // Validate validates the fields
  328. func (f *InitializeLabelsForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  329. return validate(errs, ctx.Data, f, ctx.Locale)
  330. }
  331. // __________ .__ .__ __________ __
  332. // \______ \__ __| | | | \______ \ ____ ________ __ ____ _______/ |_
  333. // | ___/ | \ | | | | _// __ \/ ____/ | \_/ __ \ / ___/\ __\
  334. // | | | | / |_| |__ | | \ ___< <_| | | /\ ___/ \___ \ | |
  335. // |____| |____/|____/____/ |____|_ /\___ >__ |____/ \___ >____ > |__|
  336. // \/ \/ |__| \/ \/
  337. // MergePullRequestForm form for merging Pull Request
  338. // swagger:model MergePullRequestOption
  339. type MergePullRequestForm struct {
  340. // required: true
  341. // enum: merge,rebase,rebase-merge,squash
  342. Do string `binding:"Required;In(merge,rebase,rebase-merge,squash)"`
  343. MergeTitleField string
  344. MergeMessageField string
  345. }
  346. // Validate validates the fields
  347. func (f *MergePullRequestForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  348. return validate(errs, ctx.Data, f, ctx.Locale)
  349. }
  350. // CodeCommentForm form for adding code comments for PRs
  351. type CodeCommentForm struct {
  352. Content string `binding:"Required"`
  353. Side string `binding:"Required;In(previous,proposed)"`
  354. Line int64
  355. TreePath string `form:"path" binding:"Required"`
  356. IsReview bool `form:"is_review"`
  357. Reply int64 `form:"reply"`
  358. }
  359. // Validate validates the fields
  360. func (f *CodeCommentForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  361. return validate(errs, ctx.Data, f, ctx.Locale)
  362. }
  363. // SubmitReviewForm for submitting a finished code review
  364. type SubmitReviewForm struct {
  365. Content string
  366. Type string `binding:"Required;In(approve,comment,reject)"`
  367. }
  368. // Validate validates the fields
  369. func (f *SubmitReviewForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  370. return validate(errs, ctx.Data, f, ctx.Locale)
  371. }
  372. // ReviewType will return the corresponding reviewtype for type
  373. func (f SubmitReviewForm) ReviewType() models.ReviewType {
  374. switch f.Type {
  375. case "approve":
  376. return models.ReviewTypeApprove
  377. case "comment":
  378. return models.ReviewTypeComment
  379. case "reject":
  380. return models.ReviewTypeReject
  381. default:
  382. return models.ReviewTypeUnknown
  383. }
  384. }
  385. // HasEmptyContent checks if the content of the review form is empty.
  386. func (f SubmitReviewForm) HasEmptyContent() bool {
  387. reviewType := f.ReviewType()
  388. return (reviewType == models.ReviewTypeComment || reviewType == models.ReviewTypeReject) &&
  389. len(strings.TrimSpace(f.Content)) == 0
  390. }
  391. // __________ .__
  392. // \______ \ ____ | | ____ _____ ______ ____
  393. // | _// __ \| | _/ __ \\__ \ / ___// __ \
  394. // | | \ ___/| |_\ ___/ / __ \_\___ \\ ___/
  395. // |____|_ /\___ >____/\___ >____ /____ >\___ >
  396. // \/ \/ \/ \/ \/ \/
  397. // NewReleaseForm form for creating release
  398. type NewReleaseForm struct {
  399. TagName string `binding:"Required;GitRefName"`
  400. Target string `form:"tag_target" binding:"Required"`
  401. Title string `binding:"Required"`
  402. Content string
  403. Draft string
  404. Prerelease bool
  405. Files []string
  406. }
  407. // Validate validates the fields
  408. func (f *NewReleaseForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  409. return validate(errs, ctx.Data, f, ctx.Locale)
  410. }
  411. // EditReleaseForm form for changing release
  412. type EditReleaseForm struct {
  413. Title string `form:"title" binding:"Required"`
  414. Content string `form:"content"`
  415. Draft string `form:"draft"`
  416. Prerelease bool `form:"prerelease"`
  417. Files []string
  418. }
  419. // Validate validates the fields
  420. func (f *EditReleaseForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  421. return validate(errs, ctx.Data, f, ctx.Locale)
  422. }
  423. // __ __.__ __ .__
  424. // / \ / \__| | _|__|
  425. // \ \/\/ / | |/ / |
  426. // \ /| | <| |
  427. // \__/\ / |__|__|_ \__|
  428. // \/ \/
  429. // NewWikiForm form for creating wiki
  430. type NewWikiForm struct {
  431. Title string `binding:"Required"`
  432. Content string `binding:"Required"`
  433. Message string
  434. }
  435. // Validate validates the fields
  436. // FIXME: use code generation to generate this method.
  437. func (f *NewWikiForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  438. return validate(errs, ctx.Data, f, ctx.Locale)
  439. }
  440. // ___________ .___.__ __
  441. // \_ _____/ __| _/|__|/ |_
  442. // | __)_ / __ | | \ __\
  443. // | \/ /_/ | | || |
  444. // /_______ /\____ | |__||__|
  445. // \/ \/
  446. // EditRepoFileForm form for changing repository file
  447. type EditRepoFileForm struct {
  448. TreePath string `binding:"Required;MaxSize(500)"`
  449. Content string `binding:"Required"`
  450. CommitSummary string `binding:"MaxSize(100)"`
  451. CommitMessage string
  452. CommitChoice string `binding:"Required;MaxSize(50)"`
  453. NewBranchName string `binding:"GitRefName;MaxSize(100)"`
  454. LastCommit string
  455. }
  456. // Validate validates the fields
  457. func (f *EditRepoFileForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  458. return validate(errs, ctx.Data, f, ctx.Locale)
  459. }
  460. // EditPreviewDiffForm form for changing preview diff
  461. type EditPreviewDiffForm struct {
  462. Content string
  463. }
  464. // Validate validates the fields
  465. func (f *EditPreviewDiffForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  466. return validate(errs, ctx.Data, f, ctx.Locale)
  467. }
  468. // ____ ___ .__ .___
  469. // | | \______ | | _________ __| _/
  470. // | | /\____ \| | / _ \__ \ / __ |
  471. // | | / | |_> > |_( <_> ) __ \_/ /_/ |
  472. // |______/ | __/|____/\____(____ /\____ |
  473. // |__| \/ \/
  474. //
  475. // UploadRepoFileForm form for uploading repository file
  476. type UploadRepoFileForm struct {
  477. TreePath string `binding:"MaxSize(500)"`
  478. CommitSummary string `binding:"MaxSize(100)"`
  479. CommitMessage string
  480. CommitChoice string `binding:"Required;MaxSize(50)"`
  481. NewBranchName string `binding:"GitRefName;MaxSize(100)"`
  482. Files []string
  483. }
  484. // Validate validates the fields
  485. func (f *UploadRepoFileForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  486. return validate(errs, ctx.Data, f, ctx.Locale)
  487. }
  488. // RemoveUploadFileForm form for removing uploaded file
  489. type RemoveUploadFileForm struct {
  490. File string `binding:"Required;MaxSize(50)"`
  491. }
  492. // Validate validates the fields
  493. func (f *RemoveUploadFileForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  494. return validate(errs, ctx.Data, f, ctx.Locale)
  495. }
  496. // ________ .__ __
  497. // \______ \ ____ | | _____/ |_ ____
  498. // | | \_/ __ \| | _/ __ \ __\/ __ \
  499. // | ` \ ___/| |_\ ___/| | \ ___/
  500. // /_______ /\___ >____/\___ >__| \___ >
  501. // \/ \/ \/ \/
  502. // DeleteRepoFileForm form for deleting repository file
  503. type DeleteRepoFileForm struct {
  504. CommitSummary string `binding:"MaxSize(100)"`
  505. CommitMessage string
  506. CommitChoice string `binding:"Required;MaxSize(50)"`
  507. NewBranchName string `binding:"GitRefName;MaxSize(100)"`
  508. LastCommit string
  509. }
  510. // Validate validates the fields
  511. func (f *DeleteRepoFileForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  512. return validate(errs, ctx.Data, f, ctx.Locale)
  513. }
  514. // ___________.__ ___________ __
  515. // \__ ___/|__| _____ ____ \__ ___/___________ ____ | | __ ___________
  516. // | | | |/ \_/ __ \ | | \_ __ \__ \ _/ ___\| |/ // __ \_ __ \
  517. // | | | | Y Y \ ___/ | | | | \// __ \\ \___| <\ ___/| | \/
  518. // |____| |__|__|_| /\___ > |____| |__| (____ /\___ >__|_ \\___ >__|
  519. // \/ \/ \/ \/ \/ \/
  520. // AddTimeManuallyForm form that adds spent time manually.
  521. type AddTimeManuallyForm struct {
  522. Hours int `binding:"Range(0,1000)"`
  523. Minutes int `binding:"Range(0,1000)"`
  524. }
  525. // Validate validates the fields
  526. func (f *AddTimeManuallyForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  527. return validate(errs, ctx.Data, f, ctx.Locale)
  528. }
  529. // SaveTopicForm form for save topics for repository
  530. type SaveTopicForm struct {
  531. Topics []string `binding:"topics;Required;"`
  532. }
  533. // DeadlineForm hold the validation rules for deadlines
  534. type DeadlineForm struct {
  535. DateString string `form:"date" binding:"Required;Size(10)"`
  536. }
  537. // Validate validates the fields
  538. func (f *DeadlineForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  539. return validate(errs, ctx.Data, f, ctx.Locale)
  540. }