From 2cc1ee3fc0573c3b7c895cb8ed16a74d710873bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kim=20=22BKC=22=20Carlb=C3=A4cker?= Date: Tue, 19 Jan 2016 14:04:24 +0100 Subject: [PATCH 1/6] Implemented participant-listing for issue-pages --- routers/repo/issue.go | 24 +++++++++++++++++++----- templates/repo/issue/view_content.tmpl | 13 +++++++++++++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/routers/repo/issue.go b/routers/repo/issue.go index a4efb68024..db55033f8a 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -589,12 +589,13 @@ func ViewIssue(ctx *middleware.Context) { } var ( - tag models.CommentTag - ok bool - marked = make(map[int64]models.CommentTag) - comment *models.Comment + tag models.CommentTag + ok bool + marked = make(map[int64]models.CommentTag) + comment *models.Comment + participants []*models.User ) - // Render comments. + // Render comments. (and fetch participants) for _, comment = range issue.Comments { if comment.Type == models.COMMENT_TYPE_COMMENT { comment.RenderedContent = string(base.RenderMarkdown([]byte(comment.Content), ctx.Repo.RepoLink, @@ -617,9 +618,22 @@ func ViewIssue(ctx *middleware.Context) { } marked[comment.PosterID] = comment.ShowTag + + already_added := false + for j := range participants { + if comment.Poster == participants[j] { + already_added = true + } + } + if !already_added { + participants = append(participants, comment.Poster) + } } } + ctx.Data["Participants"] = participants + + ctx.Data["Issue"] = issue ctx.Data["IsIssueOwner"] = ctx.Repo.IsAdmin() || (ctx.IsSigned && issue.IsPoster(ctx.User.Id)) ctx.Data["SignInLink"] = setting.AppSubUrl + "/user/login" diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl index c641d7a8ff..20baec0ef3 100644 --- a/templates/repo/issue/view_content.tmpl +++ b/templates/repo/issue/view_content.tmpl @@ -313,6 +313,19 @@ {{end}} + +
+ +
+ {{len .Participants }} Participants +
+ {{range .Participants}} + + + + {{end}} +
+
From b921161666e5abbe3b24e8f68b8e9233aaaa5826 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kim=20=22BKC=22=20Carlb=C3=A4cker?= Date: Tue, 19 Jan 2016 14:23:04 +0100 Subject: [PATCH 2/6] Name popup --- templates/repo/issue/view_content.tmpl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl index 20baec0ef3..0c1c2690d8 100644 --- a/templates/repo/issue/view_content.tmpl +++ b/templates/repo/issue/view_content.tmpl @@ -321,10 +321,13 @@
{{range .Participants}} - + {{end}}
+ From f65dedc3becf902271db1d55b6951a40c9602140 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kim=20Carlb=C3=A4cker?= Date: Wed, 20 Jan 2016 16:16:39 +0100 Subject: [PATCH 3/6] Optimize participant-fetching --- routers/repo/issue.go | 1 + 1 file changed, 1 insertion(+) diff --git a/routers/repo/issue.go b/routers/repo/issue.go index db55033f8a..88628eab90 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -623,6 +623,7 @@ func ViewIssue(ctx *middleware.Context) { for j := range participants { if comment.Poster == participants[j] { already_added = true + break } } if !already_added { From 2665728ee75c05be3555c683ada3b5a1e60a83da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kim=20=22BKC=22=20Carlb=C3=A4cker?= Date: Wed, 20 Jan 2016 17:53:28 +0100 Subject: [PATCH 4/6] Fix OP not 'participating' until commented --- routers/repo/issue.go | 1 + 1 file changed, 1 insertion(+) diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 88628eab90..80929dd77b 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -595,6 +595,7 @@ func ViewIssue(ctx *middleware.Context) { comment *models.Comment participants []*models.User ) + participants = append(participants, issue.Poster) // Render comments. (and fetch participants) for _, comment = range issue.Comments { if comment.Type == models.COMMENT_TYPE_COMMENT { From b31c7fe074dae7e51a4b2cd6aa1a9d6f2318b767 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kim=20=22BKC=22=20Carlb=C3=A4cker?= Date: Tue, 26 Jan 2016 17:53:10 +0100 Subject: [PATCH 5/6] Fixed Poster/Commenter-bug and clean-up --- routers/repo/issue.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 80929dd77b..9a6c370137 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -627,15 +627,13 @@ func ViewIssue(ctx *middleware.Context) { break } } - if !already_added { + if !already_added && !issue.IsPoster(comment.Poster.Id) { participants = append(participants, comment.Poster) } } } ctx.Data["Participants"] = participants - - ctx.Data["Issue"] = issue ctx.Data["IsIssueOwner"] = ctx.Repo.IsAdmin() || (ctx.IsSigned && issue.IsPoster(ctx.User.Id)) ctx.Data["SignInLink"] = setting.AppSubUrl + "/user/login" From 85335c5f5623d3a8d238fcc21ab6a366096434bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kim=20=22BKC=22=20Carlb=C3=A4cker?= Date: Wed, 27 Jan 2016 20:11:07 +0100 Subject: [PATCH 6/6] Go-ism :D --- routers/repo/issue.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 9a6c370137..b4deeadbc8 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -620,14 +620,14 @@ func ViewIssue(ctx *middleware.Context) { marked[comment.PosterID] = comment.ShowTag - already_added := false + isAdded := false for j := range participants { if comment.Poster == participants[j] { - already_added = true + isAdded = true break } } - if !already_added && !issue.IsPoster(comment.Poster.Id) { + if !isAdded && !issue.IsPoster(comment.Poster.Id) { participants = append(participants, comment.Poster) } }