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.

org.go 2.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Copyright 2019 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 forms
  6. import (
  7. "net/http"
  8. "code.gitea.io/gitea/modules/context"
  9. "code.gitea.io/gitea/modules/structs"
  10. "code.gitea.io/gitea/modules/web/middleware"
  11. "gitea.com/go-chi/binding"
  12. )
  13. // ________ .__ __ .__
  14. // \_____ \_______ _________ ____ |__|____________ _/ |_|__| ____ ____
  15. // / | \_ __ \/ ___\__ \ / \| \___ /\__ \\ __\ |/ _ \ / \
  16. // / | \ | \/ /_/ > __ \| | \ |/ / / __ \| | | ( <_> ) | \
  17. // \_______ /__| \___ (____ /___| /__/_____ \(____ /__| |__|\____/|___| /
  18. // \/ /_____/ \/ \/ \/ \/ \/
  19. // CreateOrgForm form for creating organization
  20. type CreateOrgForm struct {
  21. OrgName string `binding:"Required;AlphaDashDot;MaxSize(40)" locale:"org.org_name_holder"`
  22. Visibility structs.VisibleType
  23. RepoAdminChangeTeamAccess bool
  24. }
  25. // Validate validates the fields
  26. func (f *CreateOrgForm) Validate(req *http.Request, errs binding.Errors) binding.Errors {
  27. ctx := context.GetContext(req)
  28. return middleware.Validate(errs, ctx.Data, f, ctx.Locale)
  29. }
  30. // UpdateOrgSettingForm form for updating organization settings
  31. type UpdateOrgSettingForm struct {
  32. Name string `binding:"Required;AlphaDashDot;MaxSize(40)" locale:"org.org_name_holder"`
  33. FullName string `binding:"MaxSize(100)"`
  34. Description string `binding:"MaxSize(255)"`
  35. Website string `binding:"ValidUrl;MaxSize(255)"`
  36. Location string `binding:"MaxSize(50)"`
  37. Visibility structs.VisibleType
  38. MaxRepoCreation int
  39. RepoAdminChangeTeamAccess bool
  40. }
  41. // Validate validates the fields
  42. func (f *UpdateOrgSettingForm) Validate(req *http.Request, errs binding.Errors) binding.Errors {
  43. ctx := context.GetContext(req)
  44. return middleware.Validate(errs, ctx.Data, f, ctx.Locale)
  45. }
  46. // ___________
  47. // \__ ___/___ _____ _____
  48. // | |_/ __ \\__ \ / \
  49. // | |\ ___/ / __ \| Y Y \
  50. // |____| \___ >____ /__|_| /
  51. // \/ \/ \/
  52. // CreateTeamForm form for creating team
  53. type CreateTeamForm struct {
  54. TeamName string `binding:"Required;AlphaDashDot;MaxSize(30)"`
  55. Description string `binding:"MaxSize(255)"`
  56. Permission string
  57. RepoAccess string
  58. CanCreateOrgRepo bool
  59. }
  60. // Validate validates the fields
  61. func (f *CreateTeamForm) Validate(req *http.Request, errs binding.Errors) binding.Errors {
  62. ctx := context.GetContext(req)
  63. return middleware.Validate(errs, ctx.Data, f, ctx.Locale)
  64. }