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