summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZsombor <gzsombor@users.noreply.github.com>2019-02-13 09:14:17 +0100
committerLauris BH <lauris@nix.lv>2019-02-13 10:14:17 +0200
commit23414ac2a1d83f91ff47c5d8bbedebe709b1f408 (patch)
tree984c4aaad92281ae0b938f4149feb4cdaaea2f9c
parent7f38e2d0dedfc3e04994272196cda53e4ad20354 (diff)
downloadgitea-23414ac2a1d83f91ff47c5d8bbedebe709b1f408.tar.gz
gitea-23414ac2a1d83f91ff47c5d8bbedebe709b1f408.zip
Fix panic: template: repo/issue/list:210: unexpected "=" in operand (#6041)
-rw-r--r--models/issue.go19
-rw-r--r--templates/repo/issue/list.tmpl19
2 files changed, 21 insertions, 17 deletions
diff --git a/models/issue.go b/models/issue.go
index 850346674b..1421b28da2 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 f42492455c..edf88ebf41 100644
--- a/templates/repo/issue/list.tmpl
+++ b/templates/repo/issue/list.tmpl
@@ -181,7 +181,6 @@
<div class="issue list">
{{range .Issues}}
- {{ $timeStr:= TimeSinceUnix .CreatedUnix $.Lang }}
<li class="item">
<div class="ui checkbox issue-checkbox">
<input type="checkbox" data-issue-id={{.ID}}></input>
@@ -205,22 +204,8 @@
{{end}}
<p class="desc">
- {{ $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}}