From 63dae435f9d99a58b5e6c034dd2e405239f8480d Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 28 Mar 2014 09:16:12 -0400 Subject: Bug fix --- routers/repo/issue.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'routers/repo/issue.go') diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 77e35bba..c3d1a0d9 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -40,9 +40,7 @@ func Issues(ctx *middleware.Context) { ctx.Redirect("/user/login/", 302) return } - posterId = ctx.User.Id ctx.Data["ViewType"] = "created_by" - ctx.Data["IssueCreatedCount"] = models.GetUserIssueCount(posterId, ctx.Repo.Repository.Id) } // Get issues. @@ -53,6 +51,11 @@ func Issues(ctx *middleware.Context) { return } + if ctx.IsSigned { + posterId = ctx.User.Id + } + var createdByCount int + // Get posters. for i := range issues { u, err := models.GetUserById(issues[i].PosterId) @@ -61,12 +64,16 @@ func Issues(ctx *middleware.Context) { return } issues[i].Poster = u + if u.Id == posterId { + createdByCount++ + } } ctx.Data["Issues"] = issues ctx.Data["IssueCount"] = ctx.Repo.Repository.NumIssues ctx.Data["OpenCount"] = ctx.Repo.Repository.NumIssues - ctx.Repo.Repository.NumClosedIssues ctx.Data["ClosedCount"] = ctx.Repo.Repository.NumClosedIssues + ctx.Data["IssueCreatedCount"] = createdByCount ctx.Data["IsShowClosed"] = ctx.Query("state") == "closed" ctx.HTML(200, "issue/list") } -- cgit v1.2.3 From a55941ff833155cba88dbcc957b15c0ddcf07cb4 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 28 Mar 2014 17:34:07 -0400 Subject: Add auto-detect home directory --- conf/app.ini | 2 +- modules/base/conf.go | 9 +++++++-- routers/repo/issue.go | 12 ++++++------ templates/install.tmpl | 2 +- templates/issue/view.tmpl | 18 ++++++++++-------- 5 files changed, 25 insertions(+), 18 deletions(-) (limited to 'routers/repo/issue.go') diff --git a/conf/app.ini b/conf/app.ini index a3c749be..05c7745f 100644 --- a/conf/app.ini +++ b/conf/app.ini @@ -7,7 +7,7 @@ RUN_USER = git RUN_MODE = dev [repository] -ROOT = /Users/%(RUN_USER)s/git/gogs-repositories +ROOT = LANG_IGNS = Google Go|C|C++|Python|Ruby|C Sharp LICENSES = Apache v2 License|GPL v2|MIT License|Affero GPL|Artistic License 2.0|BSD (3-Clause) License diff --git a/modules/base/conf.go b/modules/base/conf.go index b3a987e6..fd77cfd3 100644 --- a/modules/base/conf.go +++ b/modules/base/conf.go @@ -291,9 +291,14 @@ func NewConfigContext() { PictureService = Cfg.MustValue("picture", "SERVICE") // Determine and create root git reposiroty path. - RepoRootPath = Cfg.MustValue("repository", "ROOT") + homeDir, err := com.HomeDir() + if err != nil { + fmt.Printf("Fail to get home directory): %v\n", err) + os.Exit(2) + } + RepoRootPath = Cfg.MustValue("repository", "ROOT", filepath.Join(homeDir, "git/gogs-repositories")) if err = os.MkdirAll(RepoRootPath, os.ModePerm); err != nil { - fmt.Printf("models.init(fail to create RepoRootPath(%s)): %v\n", RepoRootPath, err) + fmt.Printf("Fail to create RepoRootPath(%s): %v\n", RepoRootPath, err) os.Exit(2) } } diff --git a/routers/repo/issue.go b/routers/repo/issue.go index c3d1a0d9..6ac8a535 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -231,6 +231,12 @@ func Comment(ctx *middleware.Context, params martini.Params) { return } + content := ctx.Query("content") + if len(content) == 0 { + ctx.Redirect(fmt.Sprintf("/%s/%s/issues/%d", ctx.User.Name, ctx.Repo.Repository.Name, index)) + return + } + issue, err := models.GetIssueByIndex(ctx.Repo.Repository.Id, int64(index)) if err != nil { if err == models.ErrIssueNotExist { @@ -241,12 +247,6 @@ func Comment(ctx *middleware.Context, params martini.Params) { return } - content := ctx.Query("content") - if len(content) == 0 { - ctx.Handle(404, "issue.Comment", err) - return - } - switch params["action"] { case "new": if err = models.CreateComment(ctx.User.Id, issue.Id, 0, 0, content); err != nil { diff --git a/templates/install.tmpl b/templates/install.tmpl index be5a6918..872982a0 100644 --- a/templates/install.tmpl +++ b/templates/install.tmpl @@ -133,7 +133,7 @@
- +    -    + {{if .Issue.IsClosed}} + + {{else}} + + {{end}}  
-- cgit v1.2.3