gitea源码

org.go 2.8KB

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