|
@@ -12,12 +12,20 @@ import (
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
const (
|
|
|
- TEAMS = "org/team/teams"
|
|
|
|
|
- TEAM_NEW = "org/team/new"
|
|
|
|
|
- TEAM_MEMBERS = "org/team/members"
|
|
|
|
|
|
|
+ // TEAMS page template
|
|
|
|
|
+ TEAMS = "org/team/teams"
|
|
|
|
|
+
|
|
|
|
|
+ // TEAM_NEW page template
|
|
|
|
|
+ TEAM_NEW = "org/team/new"
|
|
|
|
|
+
|
|
|
|
|
+ // TEAM_MEMBERS page template
|
|
|
|
|
+ TEAM_MEMBERS = "org/team/members"
|
|
|
|
|
+
|
|
|
|
|
+ // TEAM_REPOSITORIES page template
|
|
|
TEAM_REPOSITORIES = "org/team/repositories"
|
|
TEAM_REPOSITORIES = "org/team/repositories"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+// Teams shows team page
|
|
|
func Teams(c *context.Context) {
|
|
func Teams(c *context.Context) {
|
|
|
org := c.Org.Organization
|
|
org := c.Org.Organization
|
|
|
c.Data["Title"] = org.FullName
|
|
c.Data["Title"] = org.FullName
|
|
@@ -34,6 +42,8 @@ func Teams(c *context.Context) {
|
|
|
c.HTML(200, TEAMS)
|
|
c.HTML(200, TEAMS)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// TeamsAction handle the user action
|
|
|
|
|
+// Like : join, leave, add or remove a team
|
|
|
func TeamsAction(c *context.Context) {
|
|
func TeamsAction(c *context.Context) {
|
|
|
uid := com.StrTo(c.Query("uid")).MustInt64()
|
|
uid := com.StrTo(c.Query("uid")).MustInt64()
|
|
|
if uid == 0 {
|
|
if uid == 0 {
|
|
@@ -44,14 +54,17 @@ func TeamsAction(c *context.Context) {
|
|
|
page := c.Query("page")
|
|
page := c.Query("page")
|
|
|
var err error
|
|
var err error
|
|
|
switch c.Params(":action") {
|
|
switch c.Params(":action") {
|
|
|
|
|
+ // Join a team
|
|
|
case "join":
|
|
case "join":
|
|
|
if !c.Org.IsOwner {
|
|
if !c.Org.IsOwner {
|
|
|
c.Error(404)
|
|
c.Error(404)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
err = c.Org.Team.AddMember(c.User.ID)
|
|
err = c.Org.Team.AddMember(c.User.ID)
|
|
|
|
|
+ // Leave a team
|
|
|
case "leave":
|
|
case "leave":
|
|
|
err = c.Org.Team.RemoveMember(c.User.ID)
|
|
err = c.Org.Team.RemoveMember(c.User.ID)
|
|
|
|
|
+ // Remove a team
|
|
|
case "remove":
|
|
case "remove":
|
|
|
if !c.Org.IsOwner {
|
|
if !c.Org.IsOwner {
|
|
|
c.Error(404)
|
|
c.Error(404)
|
|
@@ -59,6 +72,7 @@ func TeamsAction(c *context.Context) {
|
|
|
}
|
|
}
|
|
|
err = c.Org.Team.RemoveMember(uid)
|
|
err = c.Org.Team.RemoveMember(uid)
|
|
|
page = "team"
|
|
page = "team"
|
|
|
|
|
+ // Add a team
|
|
|
case "add":
|
|
case "add":
|
|
|
if !c.Org.IsOwner {
|
|
if !c.Org.IsOwner {
|
|
|
c.Error(404)
|
|
c.Error(404)
|
|
@@ -102,6 +116,8 @@ func TeamsAction(c *context.Context) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// TeamsRepoAction handle user actions
|
|
|
|
|
+// Like: add, remove a repository
|
|
|
func TeamsRepoAction(c *context.Context) {
|
|
func TeamsRepoAction(c *context.Context) {
|
|
|
if !c.Org.IsOwner {
|
|
if !c.Org.IsOwner {
|
|
|
c.Error(404)
|
|
c.Error(404)
|
|
@@ -136,6 +152,7 @@ func TeamsRepoAction(c *context.Context) {
|
|
|
c.Redirect(c.Org.OrgLink + "/teams/" + c.Org.Team.LowerName + "/repositories")
|
|
c.Redirect(c.Org.OrgLink + "/teams/" + c.Org.Team.LowerName + "/repositories")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// NewTeam shows the team creation page
|
|
|
func NewTeam(c *context.Context) {
|
|
func NewTeam(c *context.Context) {
|
|
|
c.Data["Title"] = c.Org.Organization.FullName
|
|
c.Data["Title"] = c.Org.Organization.FullName
|
|
|
c.Data["PageIsOrgTeams"] = true
|
|
c.Data["PageIsOrgTeams"] = true
|
|
@@ -144,6 +161,7 @@ func NewTeam(c *context.Context) {
|
|
|
c.HTML(200, TEAM_NEW)
|
|
c.HTML(200, TEAM_NEW)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// NewTeamPost creates an organization with the body fields
|
|
|
func NewTeamPost(c *context.Context, f form.CreateTeam) {
|
|
func NewTeamPost(c *context.Context, f form.CreateTeam) {
|
|
|
c.Data["Title"] = c.Org.Organization.FullName
|
|
c.Data["Title"] = c.Org.Organization.FullName
|
|
|
c.Data["PageIsOrgTeams"] = true
|
|
c.Data["PageIsOrgTeams"] = true
|
|
@@ -162,6 +180,7 @@ func NewTeamPost(c *context.Context, f form.CreateTeam) {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // Create a new team
|
|
|
if err := models.NewTeam(t); err != nil {
|
|
if err := models.NewTeam(t); err != nil {
|
|
|
c.Data["Err_TeamName"] = true
|
|
c.Data["Err_TeamName"] = true
|
|
|
switch {
|
|
switch {
|
|
@@ -178,6 +197,7 @@ func NewTeamPost(c *context.Context, f form.CreateTeam) {
|
|
|
c.Redirect(c.Org.OrgLink + "/teams/" + t.LowerName)
|
|
c.Redirect(c.Org.OrgLink + "/teams/" + t.LowerName)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// TeamMembers shows team members page
|
|
|
func TeamMembers(c *context.Context) {
|
|
func TeamMembers(c *context.Context) {
|
|
|
c.Data["Title"] = c.Org.Team.Name
|
|
c.Data["Title"] = c.Org.Team.Name
|
|
|
c.Data["PageIsOrgTeams"] = true
|
|
c.Data["PageIsOrgTeams"] = true
|
|
@@ -188,6 +208,7 @@ func TeamMembers(c *context.Context) {
|
|
|
c.HTML(200, TEAM_MEMBERS)
|
|
c.HTML(200, TEAM_MEMBERS)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// TeamRepositories shows team repositoies page
|
|
|
func TeamRepositories(c *context.Context) {
|
|
func TeamRepositories(c *context.Context) {
|
|
|
c.Data["Title"] = c.Org.Team.Name
|
|
c.Data["Title"] = c.Org.Team.Name
|
|
|
c.Data["PageIsOrgTeams"] = true
|
|
c.Data["PageIsOrgTeams"] = true
|
|
@@ -198,6 +219,7 @@ func TeamRepositories(c *context.Context) {
|
|
|
c.HTML(200, TEAM_REPOSITORIES)
|
|
c.HTML(200, TEAM_REPOSITORIES)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// EditTeam shows edit team page
|
|
|
func EditTeam(c *context.Context) {
|
|
func EditTeam(c *context.Context) {
|
|
|
c.Data["Title"] = c.Org.Organization.FullName
|
|
c.Data["Title"] = c.Org.Organization.FullName
|
|
|
c.Data["PageIsOrgTeams"] = true
|
|
c.Data["PageIsOrgTeams"] = true
|
|
@@ -206,6 +228,7 @@ func EditTeam(c *context.Context) {
|
|
|
c.HTML(200, TEAM_NEW)
|
|
c.HTML(200, TEAM_NEW)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// EditTeamPost edit team with the body fields
|
|
|
func EditTeamPost(c *context.Context, f form.CreateTeam) {
|
|
func EditTeamPost(c *context.Context, f form.CreateTeam) {
|
|
|
t := c.Org.Team
|
|
t := c.Org.Team
|
|
|
c.Data["Title"] = c.Org.Organization.FullName
|
|
c.Data["Title"] = c.Org.Organization.FullName
|
|
@@ -240,6 +263,7 @@ func EditTeamPost(c *context.Context, f form.CreateTeam) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
t.Description = f.Description
|
|
t.Description = f.Description
|
|
|
|
|
+ // Edit team
|
|
|
if err := models.UpdateTeam(t, isAuthChanged); err != nil {
|
|
if err := models.UpdateTeam(t, isAuthChanged); err != nil {
|
|
|
c.Data["Err_TeamName"] = true
|
|
c.Data["Err_TeamName"] = true
|
|
|
switch {
|
|
switch {
|
|
@@ -253,7 +277,9 @@ func EditTeamPost(c *context.Context, f form.CreateTeam) {
|
|
|
c.Redirect(c.Org.OrgLink + "/teams/" + t.LowerName)
|
|
c.Redirect(c.Org.OrgLink + "/teams/" + t.LowerName)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// DeleteTeam deletes a team
|
|
|
func DeleteTeam(c *context.Context) {
|
|
func DeleteTeam(c *context.Context) {
|
|
|
|
|
+ // Delete team
|
|
|
if err := models.DeleteTeam(c.Org.Team); err != nil {
|
|
if err := models.DeleteTeam(c.Org.Team); err != nil {
|
|
|
c.Flash.Error("DeleteTeam: " + err.Error())
|
|
c.Flash.Error("DeleteTeam: " + err.Error())
|
|
|
} else {
|
|
} else {
|