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.

90 lines
2.9 KiB

  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. "net/http"
  7. "reflect"
  8. "github.com/go-martini/martini"
  9. "github.com/gogits/gogs/modules/base"
  10. "github.com/gogits/gogs/modules/middleware/binding"
  11. )
  12. // ________ .__ __ .__
  13. // \_____ \_______ _________ ____ |__|____________ _/ |_|__| ____ ____
  14. // / | \_ __ \/ ___\__ \ / \| \___ /\__ \\ __\ |/ _ \ / \
  15. // / | \ | \/ /_/ > __ \| | \ |/ / / __ \| | | ( <_> ) | \
  16. // \_______ /__| \___ (____ /___| /__/_____ \(____ /__| |__|\____/|___| /
  17. // \/ /_____/ \/ \/ \/ \/ \/
  18. type CreateOrgForm struct {
  19. OrgName string `form:"orgname" binding:"Required;AlphaDashDot;MaxSize(30)"`
  20. Email string `form:"email" binding:"Required;Email;MaxSize(50)"`
  21. }
  22. func (f *CreateOrgForm) Name(field string) string {
  23. names := map[string]string{
  24. "OrgName": "Organization name",
  25. "Email": "E-mail address",
  26. }
  27. return names[field]
  28. }
  29. func (f *CreateOrgForm) Validate(errs *binding.Errors, req *http.Request, ctx martini.Context) {
  30. data := ctx.Get(reflect.TypeOf(base.TmplData{})).Interface().(base.TmplData)
  31. validate(errs, data, f)
  32. }
  33. type OrgSettingForm struct {
  34. DisplayName string `form:"display_name" binding:"Required;MaxSize(100)"`
  35. Email string `form:"email" binding:"Required;Email;MaxSize(50)"`
  36. Description string `form:"desc" binding:"MaxSize(255)"`
  37. Website string `form:"site" binding:"Url;MaxSize(100)"`
  38. Location string `form:"location" binding:"MaxSize(50)"`
  39. }
  40. func (f *OrgSettingForm) Name(field string) string {
  41. names := map[string]string{
  42. "DisplayName": "Display name",
  43. "Email": "E-mail address",
  44. "Description": "Description",
  45. "Website": "Website address",
  46. "Location": "Location",
  47. }
  48. return names[field]
  49. }
  50. func (f *OrgSettingForm) Validate(errors *binding.Errors, req *http.Request, context martini.Context) {
  51. data := context.Get(reflect.TypeOf(base.TmplData{})).Interface().(base.TmplData)
  52. validate(errors, data, f)
  53. }
  54. // ___________
  55. // \__ ___/___ _____ _____
  56. // | |_/ __ \\__ \ / \
  57. // | |\ ___/ / __ \| Y Y \
  58. // |____| \___ >____ /__|_| /
  59. // \/ \/ \/
  60. type CreateTeamForm struct {
  61. TeamName string `form:"name" binding:"Required;AlphaDashDot;MaxSize(30)"`
  62. Description string `form:"desc" binding:"MaxSize(255)"`
  63. Permission string `form:"permission"`
  64. }
  65. func (f *CreateTeamForm) Name(field string) string {
  66. names := map[string]string{
  67. "TeamName": "Team name",
  68. "Description": "Team description",
  69. }
  70. return names[field]
  71. }
  72. func (f *CreateTeamForm) Validate(errs *binding.Errors, req *http.Request, ctx martini.Context) {
  73. data := ctx.Get(reflect.TypeOf(base.TmplData{})).Interface().(base.TmplData)
  74. validate(errs, data, f)
  75. }