From 588a0db21869828c4ba1006855ed6454ca878068 Mon Sep 17 00:00:00 2001 From: Alexey Makhov Date: Thu, 12 Nov 2015 23:09:48 +0300 Subject: [PATCH 1/4] #1854 issue title at dashboard --- models/action.go | 7 +++++++ templates/user/dashboard/feeds.tmpl | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/models/action.go b/models/action.go index e94bb9441b..11a2de0339 100644 --- a/models/action.go +++ b/models/action.go @@ -10,6 +10,7 @@ import ( "fmt" "path" "regexp" + "strconv" "strings" "time" "unicode" @@ -136,6 +137,12 @@ func (a Action) GetIssueInfos() []string { return strings.SplitN(a.Content, "|", 2) } +func (a Action) GetIssueTitle() string { + issueID, _ := strconv.Atoi(strings.SplitN(a.Content, "|", 2)[0]) + issue, _ := GetIssueByID(int64(issueID)) + return issue.Name +} + func newRepoAction(e Engine, u *User, repo *Repository) (err error) { if err = notifyWatchers(e, &Action{ ActUserID: u.Id, diff --git a/templates/user/dashboard/feeds.tmpl b/templates/user/dashboard/feeds.tmpl index a79ff5531b..dcd856f6d7 100644 --- a/templates/user/dashboard/feeds.tmpl +++ b/templates/user/dashboard/feeds.tmpl @@ -24,7 +24,7 @@ {{$.i18n.Tr "action.push_tag" .GetRepoLink .GetBranch .GetRepoPath | Str2html}} {{else if eq .GetOpType 10}} {{ $index := index .GetIssueInfos 0}} - {{$.i18n.Tr "action.comment_issue" .GetRepoLink $index .GetRepoPath | Str2html}} + {{$.i18n.Tr "action.comment_issue" .GetRepoLink $index .GetRepoPath | Str2html}} – {{.GetIssueTitle}} {{else if eq .GetOpType 11}} {{ $index := index .GetIssueInfos 0}} {{$.i18n.Tr "action.merge_pull_request" .GetRepoLink $index .GetRepoPath | Str2html}} @@ -48,6 +48,7 @@ {{else if eq .GetOpType 7}}

{{index .GetIssueInfos 1}}

{{else if eq .GetOpType 10}} +

{{.GetIssueTitle}}

{{index .GetIssueInfos 1}}

{{else if eq .GetOpType 11}}

{{index .GetIssueInfos 1}}

From 1bfebdcdf636c53fd5bc5ae89d8e3c9d4665bf93 Mon Sep 17 00:00:00 2001 From: Alexey Makhov Date: Fri, 13 Nov 2015 00:01:51 +0300 Subject: [PATCH 2/4] #1854 improves --- models/action.go | 6 +++--- templates/user/dashboard/feeds.tmpl | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/models/action.go b/models/action.go index 11a2de0339..106f2c2eb5 100644 --- a/models/action.go +++ b/models/action.go @@ -10,12 +10,12 @@ import ( "fmt" "path" "regexp" - "strconv" "strings" "time" "unicode" "github.com/go-xorm/xorm" + "github.com/Unknwon/com" api "github.com/gogits/go-gogs-client" @@ -138,8 +138,8 @@ func (a Action) GetIssueInfos() []string { } func (a Action) GetIssueTitle() string { - issueID, _ := strconv.Atoi(strings.SplitN(a.Content, "|", 2)[0]) - issue, _ := GetIssueByID(int64(issueID)) + issueID := com.StrTo(a.GetIssueInfos()[0]).MustInt64() + issue, _ := GetIssueByID(issueID) return issue.Name } diff --git a/templates/user/dashboard/feeds.tmpl b/templates/user/dashboard/feeds.tmpl index dcd856f6d7..bff44f06bb 100644 --- a/templates/user/dashboard/feeds.tmpl +++ b/templates/user/dashboard/feeds.tmpl @@ -48,7 +48,6 @@ {{else if eq .GetOpType 7}}

{{index .GetIssueInfos 1}}

{{else if eq .GetOpType 10}} -

{{.GetIssueTitle}}

{{index .GetIssueInfos 1}}

{{else if eq .GetOpType 11}}

{{index .GetIssueInfos 1}}

From 3e7695ae91ad6007511fffd88de9ffbeacdd6a59 Mon Sep 17 00:00:00 2001 From: Alexey Makhov Date: Fri, 13 Nov 2015 00:16:51 +0300 Subject: [PATCH 3/4] #1854 improves --- models/action.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/models/action.go b/models/action.go index 106f2c2eb5..4a376f89d4 100644 --- a/models/action.go +++ b/models/action.go @@ -139,7 +139,11 @@ func (a Action) GetIssueInfos() []string { func (a Action) GetIssueTitle() string { issueID := com.StrTo(a.GetIssueInfos()[0]).MustInt64() - issue, _ := GetIssueByID(issueID) + issue, err := GetIssueByID(issueID) + if err != nil { + log.Error(4, "GetIssueByID: %v", err) + return "500 when get title" + } return issue.Name } From ee645af10766496b164bd87d1bd748e340ff100b Mon Sep 17 00:00:00 2001 From: Alexey Makhov Date: Fri, 13 Nov 2015 09:21:22 +0300 Subject: [PATCH 4/4] #1854 change issueId to issueIndex --- models/action.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/action.go b/models/action.go index 4a376f89d4..19fd9102fb 100644 --- a/models/action.go +++ b/models/action.go @@ -138,8 +138,8 @@ func (a Action) GetIssueInfos() []string { } func (a Action) GetIssueTitle() string { - issueID := com.StrTo(a.GetIssueInfos()[0]).MustInt64() - issue, err := GetIssueByID(issueID) + issueIndex := com.StrTo(a.GetIssueInfos()[0]).MustInt64() + issue, err := GetIssueByIndex(a.RepoID, issueIndex) if err != nil { log.Error(4, "GetIssueByID: %v", err) return "500 when get title"