2014-06-29 22:30:41 +02:00
|
|
|
// Copyright 2014 The Gogs Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a MIT-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2014-06-27 15:33:49 +02:00
|
|
|
package org
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/go-martini/martini"
|
2014-06-29 22:30:41 +02:00
|
|
|
|
|
|
|
"github.com/gogits/gogs/models"
|
|
|
|
"github.com/gogits/gogs/modules/base"
|
2014-06-27 15:33:49 +02:00
|
|
|
"github.com/gogits/gogs/modules/middleware"
|
|
|
|
)
|
|
|
|
|
2014-06-29 22:30:41 +02:00
|
|
|
const (
|
|
|
|
TEAMS base.TplName = "org/teams"
|
|
|
|
)
|
|
|
|
|
2014-06-27 15:33:49 +02:00
|
|
|
func Teams(ctx *middleware.Context, params martini.Params) {
|
2014-06-29 22:30:41 +02:00
|
|
|
ctx.Data["Title"] = "Organization " + params["org"] + " Teams"
|
|
|
|
|
|
|
|
org, err := models.GetUserByName(params["org"])
|
|
|
|
if err != nil {
|
|
|
|
if err == models.ErrUserNotExist {
|
|
|
|
ctx.Handle(404, "org.Teams(GetUserByName)", err)
|
|
|
|
} else {
|
|
|
|
ctx.Handle(500, "org.Teams(GetUserByName)", err)
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
ctx.Data["Org"] = org
|
|
|
|
|
|
|
|
if err = org.GetTeams(); err != nil {
|
|
|
|
ctx.Handle(500, "org.Teams(GetTeams)", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
for _, t := range org.Teams {
|
|
|
|
if err = t.GetMembers(); err != nil {
|
|
|
|
ctx.Handle(500, "org.Home(GetMembers)", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ctx.Data["Teams"] = org.Teams
|
|
|
|
|
|
|
|
ctx.HTML(200, TEAMS)
|
2014-06-27 15:33:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewTeam(ctx *middleware.Context, params martini.Params) {
|
2014-06-29 22:30:41 +02:00
|
|
|
ctx.Data["Title"] = "Organization " + params["org"] + " New Team"
|
2014-06-27 15:33:49 +02:00
|
|
|
ctx.HTML(200, "org/new_team")
|
|
|
|
}
|
2014-06-27 16:04:04 +02:00
|
|
|
|
2014-06-29 22:30:41 +02:00
|
|
|
func EditTeam(ctx *middleware.Context, params martini.Params) {
|
|
|
|
ctx.Data["Title"] = "Organization " + params["org"] + " Edit Team"
|
|
|
|
ctx.HTML(200, "org/edit_team")
|
2014-06-27 16:04:04 +02:00
|
|
|
}
|