mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-23 08:47:42 -05:00
c1b0c9e7c4
* Fix PR, milestone and label functionality if issue unit is disabled or not assigned to user * Fix multi-actions in PR page * Change error message * Fix comment update and delete functionality in PR
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
// Copyright 2017 The Gitea Authors. All rights reserved.
|
|
// Use of this source code is governed by a MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package repo
|
|
|
|
import (
|
|
"net/http"
|
|
"time"
|
|
|
|
"code.gitea.io/gitea/models"
|
|
"code.gitea.io/gitea/modules/auth"
|
|
"code.gitea.io/gitea/modules/context"
|
|
)
|
|
|
|
// AddTimeManually tracks time manually
|
|
func AddTimeManually(c *context.Context, form auth.AddTimeManuallyForm) {
|
|
issue := GetActionIssue(c)
|
|
if c.Written() {
|
|
return
|
|
}
|
|
if !c.Repo.CanUseTimetracker(issue, c.User) {
|
|
c.Handle(http.StatusNotFound, "CanUseTimetracker", nil)
|
|
return
|
|
}
|
|
url := issue.HTMLURL()
|
|
|
|
if c.HasError() {
|
|
c.Flash.Error(c.GetErrMsg())
|
|
c.Redirect(url)
|
|
return
|
|
}
|
|
|
|
total := time.Duration(form.Hours)*time.Hour + time.Duration(form.Minutes)*time.Minute
|
|
|
|
if total <= 0 {
|
|
c.Flash.Error(c.Tr("repo.issues.add_time_sum_to_small"))
|
|
c.Redirect(url, http.StatusSeeOther)
|
|
return
|
|
}
|
|
|
|
if _, err := models.AddTime(c.User, issue, int64(total.Seconds())); err != nil {
|
|
c.Handle(http.StatusInternalServerError, "AddTime", err)
|
|
return
|
|
}
|
|
|
|
c.Redirect(url, http.StatusSeeOther)
|
|
}
|