Browse Source

Расширились ограничения в поле "О себе" до 1024 #4

pull/8/head
Gitea 3 years ago
parent
commit
fc30082480
  1. 4
      models/org_team.go
  2. 4
      models/repo.go
  3. 2
      models/user/user.go
  4. 4
      modules/structs/org.go
  5. 4
      modules/structs/org_team.go
  6. 8
      modules/structs/repo.go
  7. 2
      modules/structs/user.go
  8. 2
      services/forms/org.go
  9. 2
      services/forms/repo_form.go
  10. 2
      services/forms/user_form.go

4
models/org_team.go

@ -691,8 +691,8 @@ func UpdateTeam(t *Team, authChanged, includeAllChanged bool) (err error) {
return errors.New("empty team name") return errors.New("empty team name")
} }
if len(t.Description) > 255 { if len(t.Description) > 1024 {
t.Description = t.Description[:255] t.Description = t.Description[:1024]
} }
ctx, committer, err := db.TxContext() ctx, committer, err := db.TxContext()

4
models/repo.go

@ -635,8 +635,8 @@ func DecrementRepoForkNum(ctx context.Context, repoID int64) error {
func updateRepository(ctx context.Context, repo *repo_model.Repository, visibilityChanged bool) (err error) { func updateRepository(ctx context.Context, repo *repo_model.Repository, visibilityChanged bool) (err error) {
repo.LowerName = strings.ToLower(repo.Name) repo.LowerName = strings.ToLower(repo.Name)
if utf8.RuneCountInString(repo.Description) > 255 { if utf8.RuneCountInString(repo.Description) > 1024 {
repo.Description = string([]rune(repo.Description)[:255]) repo.Description = string([]rune(repo.Description)[:1024])
} }
if utf8.RuneCountInString(repo.Website) > 255 { if utf8.RuneCountInString(repo.Website) > 255 {
repo.Website = string([]rune(repo.Website)[:255]) repo.Website = string([]rune(repo.Website)[:255])

2
models/user/user.go

@ -188,7 +188,7 @@ func (u *User) BeforeUpdate() {
u.LowerName = strings.ToLower(u.Name) u.LowerName = strings.ToLower(u.Name)
u.Location = base.TruncateString(u.Location, 255) u.Location = base.TruncateString(u.Location, 255)
u.Website = base.TruncateString(u.Website, 255) u.Website = base.TruncateString(u.Website, 255)
u.Description = base.TruncateString(u.Description, 255) u.Description = base.TruncateString(u.Description, 1024)
} }
// AfterLoad is invoked from XORM after filling all the fields of this object. // AfterLoad is invoked from XORM after filling all the fields of this object.

4
modules/structs/org.go

@ -31,7 +31,7 @@ type CreateOrgOption struct {
// required: true // required: true
UserName string `json:"username" binding:"Required"` UserName string `json:"username" binding:"Required"`
FullName string `json:"full_name"` FullName string `json:"full_name"`
Description string `json:"description" binding:"MaxSize(255)"` Description string `json:"description" binding:"MaxSize(1024)"`
Website string `json:"website" binding:"ValidUrl;MaxSize(255)"` Website string `json:"website" binding:"ValidUrl;MaxSize(255)"`
Location string `json:"location" binding:"MaxSize(50)"` Location string `json:"location" binding:"MaxSize(50)"`
// possible values are `public` (default), `limited` or `private` // possible values are `public` (default), `limited` or `private`
@ -45,7 +45,7 @@ type CreateOrgOption struct {
// EditOrgOption options for editing an organization // EditOrgOption options for editing an organization
type EditOrgOption struct { type EditOrgOption struct {
FullName string `json:"full_name"` FullName string `json:"full_name"`
Description string `json:"description" binding:"MaxSize(255)"` Description string `json:"description" binding:"MaxSize(1024)"`
Website string `json:"website" binding:"ValidUrl;MaxSize(255)"` Website string `json:"website" binding:"ValidUrl;MaxSize(255)"`
Location string `json:"location" binding:"MaxSize(50)"` Location string `json:"location" binding:"MaxSize(50)"`
// possible values are `public`, `limited` or `private` // possible values are `public`, `limited` or `private`

4
modules/structs/org_team.go

@ -26,7 +26,7 @@ type Team struct {
type CreateTeamOption struct { type CreateTeamOption struct {
// required: true // required: true
Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(30)"` Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(30)"`
Description string `json:"description" binding:"MaxSize(255)"` Description string `json:"description" binding:"MaxSize(1024)"`
IncludesAllRepositories bool `json:"includes_all_repositories"` IncludesAllRepositories bool `json:"includes_all_repositories"`
// enum: read,write,admin // enum: read,write,admin
Permission string `json:"permission"` Permission string `json:"permission"`
@ -42,7 +42,7 @@ type CreateTeamOption struct {
type EditTeamOption struct { type EditTeamOption struct {
// required: true // required: true
Name string `json:"name" binding:"AlphaDashDot;MaxSize(30)"` Name string `json:"name" binding:"AlphaDashDot;MaxSize(30)"`
Description *string `json:"description" binding:"MaxSize(255)"` Description *string `json:"description" binding:"MaxSize(1024)"`
IncludesAllRepositories *bool `json:"includes_all_repositories"` IncludesAllRepositories *bool `json:"includes_all_repositories"`
// enum: read,write,admin // enum: read,write,admin
Permission string `json:"permission"` Permission string `json:"permission"`

8
modules/structs/repo.go

@ -107,7 +107,7 @@ type CreateRepoOption struct {
// unique: true // unique: true
Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(100)"` Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(100)"`
// Description of the repository to create // Description of the repository to create
Description string `json:"description" binding:"MaxSize(255)"` Description string `json:"description" binding:"MaxSize(1024)"`
// Whether the repository is private // Whether the repository is private
Private bool `json:"private"` Private bool `json:"private"`
// Label-Set to use // Label-Set to use
@ -136,7 +136,7 @@ type EditRepoOption struct {
// unique: true // unique: true
Name *string `json:"name,omitempty" binding:"OmitEmpty;AlphaDashDot;MaxSize(100);"` Name *string `json:"name,omitempty" binding:"OmitEmpty;AlphaDashDot;MaxSize(100);"`
// a short description of the repository. // a short description of the repository.
Description *string `json:"description,omitempty" binding:"MaxSize(255)"` Description *string `json:"description,omitempty" binding:"MaxSize(1024)"`
// a URL with more information about the repository. // a URL with more information about the repository.
Website *string `json:"website,omitempty" binding:"MaxSize(255)"` Website *string `json:"website,omitempty" binding:"MaxSize(255)"`
// either `true` to make the repository private or `false` to make it public. // either `true` to make the repository private or `false` to make it public.
@ -200,7 +200,7 @@ type GenerateRepoOption struct {
// unique: true // unique: true
Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(100)"` Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(100)"`
// Description of the repository to create // Description of the repository to create
Description string `json:"description" binding:"MaxSize(255)"` Description string `json:"description" binding:"MaxSize(1024)"`
// Whether the repository is private // Whether the repository is private
Private bool `json:"private"` Private bool `json:"private"`
// include git content of default branch in template repo // include git content of default branch in template repo
@ -309,7 +309,7 @@ type MigrateRepoOptions struct {
LFS bool `json:"lfs"` LFS bool `json:"lfs"`
LFSEndpoint string `json:"lfs_endpoint"` LFSEndpoint string `json:"lfs_endpoint"`
Private bool `json:"private"` Private bool `json:"private"`
Description string `json:"description" binding:"MaxSize(255)"` Description string `json:"description" binding:"MaxSize(1024)"`
Wiki bool `json:"wiki"` Wiki bool `json:"wiki"`
Milestones bool `json:"milestones"` Milestones bool `json:"milestones"`
Labels bool `json:"labels"` Labels bool `json:"labels"`

2
modules/structs/user.go

@ -82,7 +82,7 @@ type UserSettings struct {
type UserSettingsOptions struct { type UserSettingsOptions struct {
FullName *string `json:"full_name" binding:"MaxSize(100)"` FullName *string `json:"full_name" binding:"MaxSize(100)"`
Website *string `json:"website" binding:"OmitEmpty;ValidUrl;MaxSize(255)"` Website *string `json:"website" binding:"OmitEmpty;ValidUrl;MaxSize(255)"`
Description *string `json:"description" binding:"MaxSize(255)"` Description *string `json:"description" binding:"MaxSize(1024)"`
Location *string `json:"location" binding:"MaxSize(50)"` Location *string `json:"location" binding:"MaxSize(50)"`
Language *string `json:"language"` Language *string `json:"language"`
Theme *string `json:"theme"` Theme *string `json:"theme"`

2
services/forms/org.go

@ -39,7 +39,7 @@ func (f *CreateOrgForm) Validate(req *http.Request, errs binding.Errors) binding
type UpdateOrgSettingForm struct { type UpdateOrgSettingForm struct {
Name string `binding:"Required;AlphaDashDot;MaxSize(40)" locale:"org.org_name_holder"` Name string `binding:"Required;AlphaDashDot;MaxSize(40)" locale:"org.org_name_holder"`
FullName string `binding:"MaxSize(100)"` FullName string `binding:"MaxSize(100)"`
Description string `binding:"MaxSize(255)"` Description string `binding:"MaxSize(1024)"`
Website string `binding:"ValidUrl;MaxSize(255)"` Website string `binding:"ValidUrl;MaxSize(255)"`
Location string `binding:"MaxSize(50)"` Location string `binding:"MaxSize(50)"`
Visibility structs.VisibleType Visibility structs.VisibleType

2
services/forms/repo_form.go

@ -74,7 +74,7 @@ type MigrateRepoForm struct {
LFS bool `json:"lfs"` LFS bool `json:"lfs"`
LFSEndpoint string `json:"lfs_endpoint"` LFSEndpoint string `json:"lfs_endpoint"`
Private bool `json:"private"` Private bool `json:"private"`
Description string `json:"description" binding:"MaxSize(255)"` Description string `json:"description" binding:"MaxSize(1024)"`
Wiki bool `json:"wiki"` Wiki bool `json:"wiki"`
Milestones bool `json:"milestones"` Milestones bool `json:"milestones"`
Labels bool `json:"labels"` Labels bool `json:"labels"`

2
services/forms/user_form.go

@ -245,7 +245,7 @@ type UpdateProfileForm struct {
KeepEmailPrivate bool KeepEmailPrivate bool
Website string `binding:"ValidSiteUrl;MaxSize(255)"` Website string `binding:"ValidSiteUrl;MaxSize(255)"`
Location string `binding:"MaxSize(50)"` Location string `binding:"MaxSize(50)"`
Description string `binding:"MaxSize(255)"` Description string `binding:"MaxSize(1024)"`
Visibility structs.VisibleType Visibility structs.VisibleType
KeepActivityPrivate bool KeepActivityPrivate bool
} }

Loading…
Cancel
Save