diff options
author | Unknwon <joe2010xtmf@163.com> | 2014-08-10 20:11:18 -0700 |
---|---|---|
committer | Unknwon <joe2010xtmf@163.com> | 2014-08-10 20:11:18 -0700 |
commit | 5fbf8531e6a2b74ebc9dd2a5967e82a8c9216c7a (patch) | |
tree | 8c657d037a5c87ec13cc828244ae30d3fe1168ab /routers | |
parent | 7af7584d25f48309a70083c30805ebb8454611f0 (diff) | |
download | gitea-5fbf8531e6a2b74ebc9dd2a5967e82a8c9216c7a.tar.gz gitea-5fbf8531e6a2b74ebc9dd2a5967e82a8c9216c7a.zip |
Finish new home page of organization
Diffstat (limited to 'routers')
-rw-r--r-- | routers/org/org.go | 15 | ||||
-rw-r--r-- | routers/repo/repo.go | 66 | ||||
-rw-r--r-- | routers/user/home.go | 4 |
3 files changed, 47 insertions, 38 deletions
diff --git a/routers/org/org.go b/routers/org/org.go index 9b8a13e614..fed1fd5fbc 100644 --- a/routers/org/org.go +++ b/routers/org/org.go @@ -19,34 +19,33 @@ const ( ) func Home(ctx *middleware.Context) { - ctx.Data["Title"] = "Organization " + ctx.Params(":org") + ctx.Data["Title"] = ctx.Params(":org") org, err := models.GetUserByName(ctx.Params(":org")) if err != nil { if err == models.ErrUserNotExist { - ctx.Handle(404, "org.Home(GetUserByName)", err) + ctx.Handle(404, "GetUserByName", err) } else { - ctx.Handle(500, "org.Home(GetUserByName)", err) + ctx.Handle(500, "GetUserByName", err) } return } ctx.Data["Org"] = org - ctx.Data["Repos"], err = models.GetRepositories(org.Id, - ctx.IsSigned && org.IsOrgMember(ctx.User.Id)) + ctx.Data["Repos"], err = models.GetRepositories(org.Id, ctx.IsSigned && org.IsOrgMember(ctx.User.Id)) if err != nil { - ctx.Handle(500, "org.Home(GetRepositories)", err) + ctx.Handle(500, "GetRepositories", err) return } if err = org.GetMembers(); err != nil { - ctx.Handle(500, "org.Home(GetMembers)", err) + ctx.Handle(500, "GetMembers", err) return } ctx.Data["Members"] = org.Members if err = org.GetTeams(); err != nil { - ctx.Handle(500, "org.Home(GetTeams)", err) + ctx.Handle(500, "GetTeams", err) return } ctx.Data["Teams"] = org.Teams diff --git a/routers/repo/repo.go b/routers/repo/repo.go index 9b3aca4c3d..3450ea76f7 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -204,36 +204,42 @@ func MigratePost(ctx *middleware.Context, form auth.MigrateRepoForm) { ctx.Handle(500, "MigratePost", err) } -// func Action(ctx *middleware.Context, params martini.Params) { -// var err error -// switch params["action"] { -// case "watch": -// err = models.WatchRepo(ctx.User.Id, ctx.Repo.Repository.Id, true) -// case "unwatch": -// err = models.WatchRepo(ctx.User.Id, ctx.Repo.Repository.Id, false) -// case "desc": -// if !ctx.Repo.IsOwner { -// ctx.Error(404) -// return -// } - -// ctx.Repo.Repository.Description = ctx.Query("desc") -// ctx.Repo.Repository.Website = ctx.Query("site") -// err = models.UpdateRepository(ctx.Repo.Repository) -// } - -// if err != nil { -// log.Error("repo.Action(%s): %v", params["action"], err) -// ctx.JSON(200, map[string]interface{}{ -// "ok": false, -// "err": err.Error(), -// }) -// return -// } -// ctx.JSON(200, map[string]interface{}{ -// "ok": true, -// }) -// } +func Action(ctx *middleware.Context) { + var err error + switch ctx.Params(":action") { + case "watch": + err = models.WatchRepo(ctx.User.Id, ctx.Repo.Repository.Id, true) + case "unwatch": + err = models.WatchRepo(ctx.User.Id, ctx.Repo.Repository.Id, false) + case "star": + err = models.StarRepo(ctx.User.Id, ctx.Repo.Repository.Id, true) + case "unstar": + err = models.StarRepo(ctx.User.Id, ctx.Repo.Repository.Id, false) + case "desc": + if !ctx.Repo.IsOwner { + ctx.Error(404) + return + } + + ctx.Repo.Repository.Description = ctx.Query("desc") + ctx.Repo.Repository.Website = ctx.Query("site") + err = models.UpdateRepository(ctx.Repo.Repository) + } + + if err != nil { + log.Error(4, "repo.Action(%s): %v", ctx.Params(":action"), err) + ctx.JSON(200, map[string]interface{}{ + "ok": false, + "err": err.Error(), + }) + return + } + ctx.Redirect(ctx.Repo.RepoLink) + return + ctx.JSON(200, map[string]interface{}{ + "ok": true, + }) +} func Download(ctx *middleware.Context) { ext := "." + ctx.Params(":ext") diff --git a/routers/user/home.go b/routers/user/home.go index 177fa38be3..bd33318d3c 100644 --- a/routers/user/home.go +++ b/routers/user/home.go @@ -73,6 +73,10 @@ func Dashboard(ctx *middleware.Context) { mirrors := make([]*models.Repository, 0, len(repos)/2) for _, repo := range repos { if repo.IsMirror { + if err = repo.GetMirror(); err != nil { + ctx.Handle(500, "GetMirror: "+repo.Name, err) + return + } mirrors = append(mirrors, repo) } } |