|
|
|
@@ -27,15 +27,11 @@ const ( |
|
|
|
tplTeams base.TplName = "org/team/teams" |
|
|
|
tplCourseTeams base.TplName = "org/team/courseTeams" |
|
|
|
// tplTeamNew template path for create new team page |
|
|
|
tplTeamNew base.TplName = "org/team/new" |
|
|
|
tplTeamCourseNew base.TplName = "org/team/course_new" |
|
|
|
|
|
|
|
tplTeamNew base.TplName = "org/team/new" |
|
|
|
// tplTeamMembers template path for showing team members page |
|
|
|
tplTeamMembers base.TplName = "org/team/members" |
|
|
|
tplCourseTeamMembers base.TplName = "org/team/course_members" |
|
|
|
tplTeamMembers base.TplName = "org/team/members" |
|
|
|
// tplTeamRepositories template path for showing team repositories page |
|
|
|
tplTeamRepositories base.TplName = "org/team/repositories" |
|
|
|
tplCousreTeamRepositories base.TplName = "org/team/course_repositories" |
|
|
|
tplTeamRepositories base.TplName = "org/team/repositories" |
|
|
|
) |
|
|
|
|
|
|
|
// Teams render teams list page |
|
|
|
@@ -51,17 +47,12 @@ func Teams(ctx *context.Context) { |
|
|
|
} |
|
|
|
} |
|
|
|
ctx.Data["Teams"] = org.Teams |
|
|
|
|
|
|
|
ctx.HTML(200, getTemplate(org, tplCourseTeams, tplTeams)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
func getTemplate(org *models.User, courseTemplate base.TplName, normalTemplate base.TplName) base.TplName { |
|
|
|
if setting.Course.OrgName == org.Name { |
|
|
|
return courseTemplate |
|
|
|
ctx.HTML(200, tplCourseTeams) |
|
|
|
} else { |
|
|
|
return normalTemplate |
|
|
|
ctx.HTML(200, tplTeams) |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// TeamsAction response for join, leave, remove, add operations to team |
|
|
|
@@ -200,7 +191,7 @@ func NewTeam(ctx *context.Context) { |
|
|
|
ctx.Data["PageIsOrgTeamsNew"] = true |
|
|
|
ctx.Data["Team"] = &models.Team{} |
|
|
|
ctx.Data["Units"] = models.Units |
|
|
|
ctx.HTML(200, getTemplate(ctx.Org.Organization, tplTeamCourseNew, tplTeamNew)) |
|
|
|
ctx.HTML(200, tplTeamNew) |
|
|
|
} |
|
|
|
|
|
|
|
// NewTeamPost response for create new team |
|
|
|
@@ -210,7 +201,6 @@ func NewTeamPost(ctx *context.Context, form auth.CreateTeamForm) { |
|
|
|
ctx.Data["PageIsOrgTeamsNew"] = true |
|
|
|
ctx.Data["Units"] = models.Units |
|
|
|
var includesAllRepositories = (form.RepoAccess == "all") |
|
|
|
template := getTemplate(ctx.Org.Organization, tplTeamCourseNew, tplTeamNew) |
|
|
|
|
|
|
|
t := &models.Team{ |
|
|
|
OrgID: ctx.Org.Organization.ID, |
|
|
|
@@ -235,12 +225,12 @@ func NewTeamPost(ctx *context.Context, form auth.CreateTeamForm) { |
|
|
|
ctx.Data["Team"] = t |
|
|
|
|
|
|
|
if ctx.HasError() { |
|
|
|
ctx.HTML(200, template) |
|
|
|
ctx.HTML(200, tplTeamNew) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if t.Authorize < models.AccessModeAdmin && len(form.Units) == 0 { |
|
|
|
ctx.RenderWithErr(ctx.Tr("form.team_no_units_error"), template, &form) |
|
|
|
ctx.RenderWithErr(ctx.Tr("form.team_no_units_error"), tplTeamNew, &form) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
@@ -248,7 +238,7 @@ func NewTeamPost(ctx *context.Context, form auth.CreateTeamForm) { |
|
|
|
ctx.Data["Err_TeamName"] = true |
|
|
|
switch { |
|
|
|
case models.IsErrTeamAlreadyExist(err): |
|
|
|
ctx.RenderWithErr(ctx.Tr("form.team_name_been_taken"), template, &form) |
|
|
|
ctx.RenderWithErr(ctx.Tr("form.team_name_been_taken"), tplTeamNew, &form) |
|
|
|
default: |
|
|
|
ctx.ServerError("NewTeam", err) |
|
|
|
} |
|
|
|
@@ -267,7 +257,7 @@ func TeamMembers(ctx *context.Context) { |
|
|
|
ctx.ServerError("GetMembers", err) |
|
|
|
return |
|
|
|
} |
|
|
|
ctx.HTML(200, getTemplate(ctx.Org.Organization, tplCourseTeamMembers, tplTeamMembers)) |
|
|
|
ctx.HTML(200, tplTeamMembers) |
|
|
|
} |
|
|
|
|
|
|
|
// TeamRepositories show the repositories of team |
|
|
|
@@ -279,7 +269,7 @@ func TeamRepositories(ctx *context.Context) { |
|
|
|
ctx.ServerError("GetRepositories", err) |
|
|
|
return |
|
|
|
} |
|
|
|
ctx.HTML(200, getTemplate(ctx.Org.Organization, tplCousreTeamRepositories, tplTeamRepositories)) |
|
|
|
ctx.HTML(200, tplTeamRepositories) |
|
|
|
} |
|
|
|
|
|
|
|
// EditTeam render team edit page |
|
|
|
@@ -289,7 +279,7 @@ func EditTeam(ctx *context.Context) { |
|
|
|
ctx.Data["team_name"] = ctx.Org.Team.Name |
|
|
|
ctx.Data["desc"] = ctx.Org.Team.Description |
|
|
|
ctx.Data["Units"] = models.Units |
|
|
|
ctx.HTML(200, getTemplate(ctx.Org.Organization, tplTeamCourseNew, tplTeamNew)) |
|
|
|
ctx.HTML(200, tplTeamNew) |
|
|
|
} |
|
|
|
|
|
|
|
// EditTeamPost response for modify team information |
|
|
|
@@ -299,7 +289,6 @@ func EditTeamPost(ctx *context.Context, form auth.CreateTeamForm) { |
|
|
|
ctx.Data["PageIsOrgTeams"] = true |
|
|
|
ctx.Data["Team"] = t |
|
|
|
ctx.Data["Units"] = models.Units |
|
|
|
template := getTemplate(ctx.Org.Organization, tplTeamCourseNew, tplTeamNew) |
|
|
|
|
|
|
|
isAuthChanged := false |
|
|
|
isIncludeAllChanged := false |
|
|
|
@@ -338,12 +327,12 @@ func EditTeamPost(ctx *context.Context, form auth.CreateTeamForm) { |
|
|
|
t.CanCreateOrgRepo = form.CanCreateOrgRepo |
|
|
|
|
|
|
|
if ctx.HasError() { |
|
|
|
ctx.HTML(200, template) |
|
|
|
ctx.HTML(200, tplTeamNew) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if t.Authorize < models.AccessModeAdmin && len(form.Units) == 0 { |
|
|
|
ctx.RenderWithErr(ctx.Tr("form.team_no_units_error"), template, &form) |
|
|
|
ctx.RenderWithErr(ctx.Tr("form.team_no_units_error"), tplTeamNew, &form) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
@@ -351,7 +340,7 @@ func EditTeamPost(ctx *context.Context, form auth.CreateTeamForm) { |
|
|
|
ctx.Data["Err_TeamName"] = true |
|
|
|
switch { |
|
|
|
case models.IsErrTeamAlreadyExist(err): |
|
|
|
ctx.RenderWithErr(ctx.Tr("form.team_name_been_taken"), template, &form) |
|
|
|
ctx.RenderWithErr(ctx.Tr("form.team_name_been_taken"), tplTeamNew, &form) |
|
|
|
default: |
|
|
|
ctx.ServerError("UpdateTeam", err) |
|
|
|
} |
|
|
|
|