Browse Source

org/team: make 'new' as reserved for team name (#3789)

pull/4122/head
Unknwon 8 years ago
parent
commit
f4aedda13a
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
  1. 1
      conf/locale/locale_en-US.ini
  2. 2
      gogs.go
  3. 13
      models/org_team.go
  4. 1
      models/repo.go
  5. 48
      modules/bindata/bindata.go
  6. 2
      routers/org/teams.go
  7. 2
      templates/.VERSION

1
conf/locale/locale_en-US.ini

@ -827,6 +827,7 @@ team_permission_desc = What permission level should this team have?
form.name_reserved = Organization name '%s' is reserved.
form.name_pattern_not_allowed = Organization name pattern '%s' is not allowed.
form.team_name_reserved = Team name '%s' is reserved.
settings = Settings
settings.options = Options

2
gogs.go

@ -16,7 +16,7 @@ import (
"github.com/gogits/gogs/modules/setting"
)
const APP_VER = "0.9.145.0213"
const APP_VER = "0.9.146.0214"
func init() {
setting.AppVer = APP_VER

13
models/org_team.go

@ -206,11 +206,24 @@ func (t *Team) RemoveRepository(repoID int64) error {
return sess.Commit()
}
var reservedTeamNames = []string{"new"}
// IsUsableTeamName return an error if given name is a reserved name or pattern.
func IsUsableTeamName(name string) error {
return isUsableName(reservedTeamNames, nil, name)
}
// NewTeam creates a record of new team.
// It's caller's responsibility to assign organization ID.
func NewTeam(t *Team) error {
if len(t.Name) == 0 {
return errors.New("empty team name")
} else if t.OrgID == 0 {
return errors.New("OrgID is not assigned")
}
if err := IsUsableTeamName(t.Name); err != nil {
return err
}
has, err := x.Id(t.OrgID).Get(new(User))

1
models/repo.go

@ -906,6 +906,7 @@ var (
reservedRepoPatterns = []string{"*.git", "*.wiki"}
)
// IsUsableRepoName return an error if given name is a reserved name or pattern.
func IsUsableRepoName(name string) error {
return isUsableName(reservedRepoNames, reservedRepoPatterns, name)
}

48
modules/bindata/bindata.go

File diff suppressed because one or more lines are too long

2
routers/org/teams.go

@ -172,6 +172,8 @@ func NewTeamPost(ctx *context.Context, form auth.CreateTeamForm) {
switch {
case models.IsErrTeamAlreadyExist(err):
ctx.RenderWithErr(ctx.Tr("form.team_name_been_taken"), TEAM_NEW, &form)
case models.IsErrNameReserved(err):
ctx.RenderWithErr(ctx.Tr("org.form.team_name_reserved", err.(models.ErrNameReserved).Name), TEAM_NEW, &form)
default:
ctx.Handle(500, "NewTeam", err)
}

2
templates/.VERSION

@ -1 +1 @@
0.9.145.0213
0.9.146.0214
Loading…
Cancel
Save