From 5c4bc3c848fb4bd46ad5ceeacd82cdfa8f2b5635 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sat, 26 Jul 2014 02:28:04 -0400 Subject: Huge updates!!!!! Be careful to merge!!!! --- routers/org/members.go | 6 ++---- routers/org/org.go | 36 +++++++++++++++++------------------- routers/org/teams.go | 26 ++++++++++++-------------- 3 files changed, 31 insertions(+), 37 deletions(-) (limited to 'routers/org') diff --git a/routers/org/members.go b/routers/org/members.go index c6f49b14bd..ac278d4e6d 100644 --- a/routers/org/members.go +++ b/routers/org/members.go @@ -5,12 +5,10 @@ package org import ( - "github.com/go-martini/martini" - "github.com/gogits/gogs/modules/middleware" ) -func Members(ctx *middleware.Context, params martini.Params) { - ctx.Data["Title"] = "Organization " + params["org"] + " Members" +func Members(ctx *middleware.Context) { + ctx.Data["Title"] = "Organization " + ctx.Params(":org") + " Members" ctx.HTML(200, "org/members") } diff --git a/routers/org/org.go b/routers/org/org.go index 4c8854974d..74527d6008 100644 --- a/routers/org/org.go +++ b/routers/org/org.go @@ -5,9 +5,7 @@ package org import ( - "github.com/go-martini/martini" - - "github.com/gogits/gogs-ng/models" + "github.com/gogits/gogs/models" "github.com/gogits/gogs/modules/auth" "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/log" @@ -21,10 +19,10 @@ const ( SETTINGS base.TplName = "org/settings" ) -func Home(ctx *middleware.Context, params martini.Params) { - ctx.Data["Title"] = "Organization " + params["org"] +func Home(ctx *middleware.Context) { + ctx.Data["Title"] = "Organization " + ctx.Params(":org") - org, err := models.GetUserByName(params["org"]) + org, err := models.GetUserByName(ctx.Params(":org")) if err != nil { if err == models.ErrUserNotExist { ctx.Handle(404, "org.Home(GetUserByName)", err) @@ -99,12 +97,12 @@ func NewPost(ctx *middleware.Context, form auth.CreateOrgForm) { ctx.Redirect("/org/" + form.OrgName + "/dashboard") } -func Dashboard(ctx *middleware.Context, params martini.Params) { +func Dashboard(ctx *middleware.Context) { ctx.Data["Title"] = "Dashboard" ctx.Data["PageIsUserDashboard"] = true ctx.Data["PageIsOrgDashboard"] = true - org, err := models.GetUserByName(params["org"]) + org, err := models.GetUserByName(ctx.Params(":org")) if err != nil { if err == models.ErrUserNotExist { ctx.Handle(404, "org.Dashboard(GetUserByName)", err) @@ -114,11 +112,11 @@ func Dashboard(ctx *middleware.Context, params martini.Params) { return } - // if err := ctx.User.GetOrganizations(); err != nil { - // ctx.Handle(500, "home.Dashboard(GetOrganizations)", err) - // return - // } - // ctx.Data["Orgs"] = ctx.User.Orgs + if err := ctx.User.GetOrganizations(); err != nil { + ctx.Handle(500, "home.Dashboard(GetOrganizations)", err) + return + } + ctx.Data["Orgs"] = ctx.User.Orgs ctx.Data["ContextUser"] = org ctx.Data["MyRepos"], err = models.GetRepositories(org.Id, true) @@ -137,10 +135,10 @@ func Dashboard(ctx *middleware.Context, params martini.Params) { ctx.HTML(200, user.DASHBOARD) } -func Settings(ctx *middleware.Context, params martini.Params) { +func Settings(ctx *middleware.Context) { ctx.Data["Title"] = "Settings" - org, err := models.GetUserByName(params["org"]) + org, err := models.GetUserByName(ctx.Params(":org")) if err != nil { if err == models.ErrUserNotExist { ctx.Handle(404, "org.Settings(GetUserByName)", err) @@ -154,10 +152,10 @@ func Settings(ctx *middleware.Context, params martini.Params) { ctx.HTML(200, SETTINGS) } -func SettingsPost(ctx *middleware.Context, params martini.Params, form auth.OrgSettingForm) { +func SettingsPost(ctx *middleware.Context, form auth.OrgSettingForm) { ctx.Data["Title"] = "Settings" - org, err := models.GetUserByName(params["org"]) + org, err := models.GetUserByName(ctx.Params(":org")) if err != nil { if err == models.ErrUserNotExist { ctx.Handle(404, "org.SettingsPost(GetUserByName)", err) @@ -187,10 +185,10 @@ func SettingsPost(ctx *middleware.Context, params martini.Params, form auth.OrgS ctx.Redirect("/org/" + org.Name + "/settings") } -func DeletePost(ctx *middleware.Context, params martini.Params) { +func DeletePost(ctx *middleware.Context) { ctx.Data["Title"] = "Settings" - org, err := models.GetUserByName(params["org"]) + org, err := models.GetUserByName(ctx.Params(":org")) if err != nil { if err == models.ErrUserNotExist { ctx.Handle(404, "org.DeletePost(GetUserByName)", err) diff --git a/routers/org/teams.go b/routers/org/teams.go index 0b17f46368..d494ddc04d 100644 --- a/routers/org/teams.go +++ b/routers/org/teams.go @@ -5,8 +5,6 @@ package org import ( - "github.com/go-martini/martini" - "github.com/gogits/gogs/models" "github.com/gogits/gogs/modules/auth" "github.com/gogits/gogs/modules/base" @@ -19,10 +17,10 @@ const ( TEAM_NEW base.TplName = "org/team_new" ) -func Teams(ctx *middleware.Context, params martini.Params) { - ctx.Data["Title"] = "Organization " + params["org"] + " Teams" +func Teams(ctx *middleware.Context) { + ctx.Data["Title"] = "Organization " + ctx.Params(":org") + " Teams" - org, err := models.GetUserByName(params["org"]) + org, err := models.GetUserByName(ctx.Params(":org")) if err != nil { if err == models.ErrUserNotExist { ctx.Handle(404, "org.Teams(GetUserByName)", err) @@ -48,8 +46,8 @@ func Teams(ctx *middleware.Context, params martini.Params) { ctx.HTML(200, TEAMS) } -func NewTeam(ctx *middleware.Context, params martini.Params) { - org, err := models.GetUserByName(params["org"]) +func NewTeam(ctx *middleware.Context) { + org, err := models.GetUserByName(ctx.Params(":org")) if err != nil { if err == models.ErrUserNotExist { ctx.Handle(404, "org.NewTeam(GetUserByName)", err) @@ -69,8 +67,8 @@ func NewTeam(ctx *middleware.Context, params martini.Params) { ctx.HTML(200, TEAM_NEW) } -func NewTeamPost(ctx *middleware.Context, params martini.Params, form auth.CreateTeamForm) { - org, err := models.GetUserByName(params["org"]) +func NewTeamPost(ctx *middleware.Context, form auth.CreateTeamForm) { + org, err := models.GetUserByName(ctx.Params(":org")) if err != nil { if err == models.ErrUserNotExist { ctx.Handle(404, "org.NewTeamPost(GetUserByName)", err) @@ -125,12 +123,12 @@ func NewTeamPost(ctx *middleware.Context, params martini.Params, form auth.Creat ctx.Redirect("/org/" + org.LowerName + "/teams/" + t.LowerName) } -func EditTeam(ctx *middleware.Context, params martini.Params) { - ctx.Data["Title"] = "Organization " + params["org"] + " Edit Team" +func EditTeam(ctx *middleware.Context) { + ctx.Data["Title"] = "Organization " + ctx.Params(":org") + " Edit Team" ctx.HTML(200, "org/edit_team") } -func SingleTeam(ctx *middleware.Context,params martini.Params){ - ctx.Data["Title"] = "single-team"+params["org"] - ctx.HTML(200,"org/team") +func SingleTeam(ctx *middleware.Context) { + ctx.Data["Title"] = "single-team" + ctx.Params(":org") + ctx.HTML(200, "org/team") } -- cgit v1.2.3