Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix panic: template: repo/issue/list:210: unexpected "=" in operand #6041

Merged
merged 1 commit into from
Feb 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions models/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 2 additions & 17 deletions templates/repo/issue/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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}}
Expand Down