|
|
@ -157,12 +157,6 @@ func NewTeamPost(ctx *middleware.Context, form auth.CreateTeamForm) { |
|
|
|
ctx.Data["Title"] = ctx.Org.Organization.FullName |
|
|
|
ctx.Data["Title"] = ctx.Org.Organization.FullName |
|
|
|
ctx.Data["PageIsOrgTeams"] = true |
|
|
|
ctx.Data["PageIsOrgTeams"] = true |
|
|
|
ctx.Data["PageIsOrgTeamsNew"] = true |
|
|
|
ctx.Data["PageIsOrgTeamsNew"] = true |
|
|
|
ctx.Data["Team"] = &models.Team{} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ctx.HasError() { |
|
|
|
|
|
|
|
ctx.HTML(200, TEAM_NEW) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Validate permission level.
|
|
|
|
// Validate permission level.
|
|
|
|
var auth models.AccessMode |
|
|
|
var auth models.AccessMode |
|
|
@ -178,28 +172,30 @@ func NewTeamPost(ctx *middleware.Context, form auth.CreateTeamForm) { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
org := ctx.Org.Organization |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
t := &models.Team{ |
|
|
|
t := &models.Team{ |
|
|
|
OrgID: org.Id, |
|
|
|
OrgID: ctx.Org.Organization.Id, |
|
|
|
Name: form.TeamName, |
|
|
|
Name: form.TeamName, |
|
|
|
Description: form.Description, |
|
|
|
Description: form.Description, |
|
|
|
Authorize: auth, |
|
|
|
Authorize: auth, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
ctx.Data["Team"] = t |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ctx.HasError() { |
|
|
|
|
|
|
|
ctx.HTML(200, TEAM_NEW) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if err := models.NewTeam(t); err != nil { |
|
|
|
if err := models.NewTeam(t); err != nil { |
|
|
|
switch err { |
|
|
|
|
|
|
|
case models.ErrTeamNameIllegal: |
|
|
|
|
|
|
|
ctx.Data["Err_TeamName"] = true |
|
|
|
|
|
|
|
ctx.RenderWithErr(ctx.Tr("form.illegal_team_name"), TEAM_NEW, &form) |
|
|
|
|
|
|
|
case models.ErrTeamAlreadyExist: |
|
|
|
|
|
|
|
ctx.Data["Err_TeamName"] = true |
|
|
|
ctx.Data["Err_TeamName"] = true |
|
|
|
|
|
|
|
switch { |
|
|
|
|
|
|
|
case models.IsErrTeamAlreadyExist(err): |
|
|
|
ctx.RenderWithErr(ctx.Tr("form.team_name_been_taken"), TEAM_NEW, &form) |
|
|
|
ctx.RenderWithErr(ctx.Tr("form.team_name_been_taken"), TEAM_NEW, &form) |
|
|
|
default: |
|
|
|
default: |
|
|
|
ctx.Handle(500, "NewTeam", err) |
|
|
|
ctx.Handle(500, "NewTeam", err) |
|
|
|
} |
|
|
|
} |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
log.Trace("Team created: %s/%s", org.Name, t.Name) |
|
|
|
log.Trace("Team created: %s/%s", ctx.Org.Organization.Name, t.Name) |
|
|
|
ctx.Redirect(ctx.Org.OrgLink + "/teams/" + t.LowerName) |
|
|
|
ctx.Redirect(ctx.Org.OrgLink + "/teams/" + t.LowerName) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -235,8 +231,7 @@ func EditTeamPost(ctx *middleware.Context, form auth.CreateTeamForm) { |
|
|
|
t := ctx.Org.Team |
|
|
|
t := ctx.Org.Team |
|
|
|
ctx.Data["Title"] = ctx.Org.Organization.FullName |
|
|
|
ctx.Data["Title"] = ctx.Org.Organization.FullName |
|
|
|
ctx.Data["PageIsOrgTeams"] = true |
|
|
|
ctx.Data["PageIsOrgTeams"] = true |
|
|
|
ctx.Data["team_name"] = t.Name |
|
|
|
ctx.Data["Team"] = t |
|
|
|
ctx.Data["desc"] = t.Description |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ctx.HasError() { |
|
|
|
if ctx.HasError() { |
|
|
|
ctx.HTML(200, TEAM_NEW) |
|
|
|
ctx.HTML(200, TEAM_NEW) |
|
|
@ -267,10 +262,11 @@ func EditTeamPost(ctx *middleware.Context, form auth.CreateTeamForm) { |
|
|
|
} |
|
|
|
} |
|
|
|
t.Description = form.Description |
|
|
|
t.Description = form.Description |
|
|
|
if err := models.UpdateTeam(t, isAuthChanged); err != nil { |
|
|
|
if err := models.UpdateTeam(t, isAuthChanged); err != nil { |
|
|
|
if err == models.ErrTeamNameIllegal { |
|
|
|
|
|
|
|
ctx.Data["Err_TeamName"] = true |
|
|
|
ctx.Data["Err_TeamName"] = true |
|
|
|
ctx.RenderWithErr(ctx.Tr("form.illegal_team_name"), TEAM_NEW, &form) |
|
|
|
switch { |
|
|
|
} else { |
|
|
|
case models.IsErrTeamAlreadyExist(err): |
|
|
|
|
|
|
|
ctx.RenderWithErr(ctx.Tr("form.team_name_been_taken"), TEAM_NEW, &form) |
|
|
|
|
|
|
|
default: |
|
|
|
ctx.Handle(500, "UpdateTeam", err) |
|
|
|
ctx.Handle(500, "UpdateTeam", err) |
|
|
|
} |
|
|
|
} |
|
|
|
return |
|
|
|
return |
|
|
|