From 23414ac2a1d83f91ff47c5d8bbedebe709b1f408 Mon Sep 17 00:00:00 2001 From: Zsombor Date: Wed, 13 Feb 2019 09:14:17 +0100 Subject: [PATCH] Fix panic: template: repo/issue/list:210: unexpected "=" in operand (#6041) --- models/issue.go | 19 +++++++++++++++++++ templates/repo/issue/list.tmpl | 19 ++----------------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/models/issue.go b/models/issue.go index 850346674..1421b28da 100644 --- a/models/issue.go +++ b/models/issue.go @@ -953,6 +953,25 @@ func (issue *Issue) GetTasksDone() int { return len(issueTasksDonePat.FindAllStringIndex(issue.Content, -1)) } +// GetLastEventTimestamp returns the last user visible event timestamp, either the creation of this issue or the close. +func (issue *Issue) GetLastEventTimestamp() util.TimeStamp { + if issue.IsClosed { + return issue.ClosedUnix + } + return issue.CreatedUnix +} + +// GetLastEventLabel returns the localization label for the current issue. +func (issue *Issue) GetLastEventLabel() string { + if issue.IsClosed { + if issue.IsPull && issue.PullRequest.HasMerged { + return "repo.pulls.merged_by" + } + return "repo.issues.closed_by" + } + return "repo.issues.opened_by" +} + // NewIssueOptions represents the options of a new issue. type NewIssueOptions struct { Repo *Repository diff --git a/templates/repo/issue/list.tmpl b/templates/repo/issue/list.tmpl index f42492455..edf88ebf4 100644 --- a/templates/repo/issue/list.tmpl +++ b/templates/repo/issue/list.tmpl @@ -181,7 +181,6 @@
{{range .Issues}} - {{ $timeStr:= TimeSinceUnix .CreatedUnix $.Lang }}
  • @@ -205,22 +204,8 @@ {{end}}

    - {{ $textToTranslate := "repo.issues.opened_by" }} - {{ if not .IsClosed }} - {{ $timeStr = TimeSinceUnix .CreatedUnix $.Lang }} - {{ else if and .IsClosed .IsPull }} - {{ $timeStr = TimeSinceUnix .ClosedUnix $.Lang }} - {{ if .PullRequest.HasMerged }} - {{ $textToTranslate = "repo.pulls.merged_by"}} - {{ else }} - {{ $textToTranslate = "repo.issues.closed_by"}} - {{ end }} - {{ else }} - {{ $timeStr = TimeSinceUnix .ClosedUnix $.Lang }} - {{ $textToTranslate = "repo.issues.closed_by"}} - {{ end }} - - {{$.i18n.Tr $textToTranslate $timeStr .Poster.HomeLink .Poster.Name | Safe}} + {{ $timeStr := TimeSinceUnix .GetLastEventTimestamp $.Lang }} + {{$.i18n.Tr .GetLastEventLabel $timeStr .Poster.HomeLink .Poster.Name | Safe}} {{$tasks := .GetTasks}} {{if gt $tasks 0}}