diff options
Diffstat (limited to 'routers/repo/issue.go')
-rw-r--r-- | routers/repo/issue.go | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/routers/repo/issue.go b/routers/repo/issue.go index d1c5e1fe71..0cd4edabb6 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -589,6 +589,38 @@ func ViewIssue(ctx *context.Context) { comment *models.Comment participants = make([]*models.User, 1, 10) ) + if ctx.Repo.Repository.IsTimetrackerEnabled() { + if ctx.IsSigned { + // Deal with the stopwatch + ctx.Data["IsStopwatchRunning"] = models.StopwatchExists(ctx.User.ID, issue.ID) + if !ctx.Data["IsStopwatchRunning"].(bool) { + var exists bool + var sw *models.Stopwatch + if exists, sw, err = models.HasUserStopwatch(ctx.User.ID); err != nil { + ctx.Handle(500, "HasUserStopwatch", err) + return + } + ctx.Data["HasUserStopwatch"] = exists + if exists { + // Add warning if the user has already a stopwatch + var otherIssue *models.Issue + if otherIssue, err = models.GetIssueByID(sw.IssueID); err != nil { + ctx.Handle(500, "GetIssueByID", err) + return + } + // Add link to the issue of the already running stopwatch + ctx.Data["OtherStopwatchURL"] = otherIssue.HTMLURL() + } + } + ctx.Data["CanUseTimetracker"] = ctx.Repo.CanUseTimetracker(issue, ctx.User) + } else { + ctx.Data["CanUseTimetracker"] = false + } + if ctx.Data["WorkingUsers"], err = models.TotalTimes(models.FindTrackedTimesOptions{IssueID: issue.ID}); err != nil { + ctx.Handle(500, "TotalTimes", err) + return + } + } // Render comments and and fetch participants. participants[0] = issue.Poster @@ -683,7 +715,8 @@ func ViewIssue(ctx *context.Context) { ctx.HTML(200, tplIssueView) } -func getActionIssue(ctx *context.Context) *models.Issue { +// GetActionIssue will return the issue which is used in the context. +func GetActionIssue(ctx *context.Context) *models.Issue { issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index")) if err != nil { if models.IsErrIssueNotExist(err) { @@ -720,7 +753,7 @@ func getActionIssues(ctx *context.Context) []*models.Issue { // UpdateIssueTitle change issue's title func UpdateIssueTitle(ctx *context.Context) { - issue := getActionIssue(ctx) + issue := GetActionIssue(ctx) if ctx.Written() { return } @@ -748,7 +781,7 @@ func UpdateIssueTitle(ctx *context.Context) { // UpdateIssueContent change issue's content func UpdateIssueContent(ctx *context.Context) { - issue := getActionIssue(ctx) + issue := GetActionIssue(ctx) if ctx.Written() { return } |