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

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