本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.0KB

  1. // Copyright 2017 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package repo
  5. import (
  6. "net/http"
  7. "time"
  8. "code.gitea.io/gitea/models"
  9. "code.gitea.io/gitea/modules/auth"
  10. "code.gitea.io/gitea/modules/context"
  11. )
  12. // AddTimeManually tracks time manually
  13. func AddTimeManually(c *context.Context, form auth.AddTimeManuallyForm) {
  14. issue := GetActionIssue(c)
  15. if c.Written() {
  16. return
  17. }
  18. if !c.Repo.CanUseTimetracker(issue, c.User) {
  19. c.NotFound("CanUseTimetracker", nil)
  20. return
  21. }
  22. url := issue.HTMLURL()
  23. if c.HasError() {
  24. c.Flash.Error(c.GetErrMsg())
  25. c.Redirect(url)
  26. return
  27. }
  28. total := time.Duration(form.Hours)*time.Hour + time.Duration(form.Minutes)*time.Minute
  29. if total <= 0 {
  30. c.Flash.Error(c.Tr("repo.issues.add_time_sum_to_small"))
  31. c.Redirect(url, http.StatusSeeOther)
  32. return
  33. }
  34. if _, err := models.AddTime(c.User, issue, int64(total.Seconds())); err != nil {
  35. c.ServerError("AddTime", err)
  36. return
  37. }
  38. c.Redirect(url, http.StatusSeeOther)
  39. }
上海开阖软件有限公司 沪ICP备12045867号-1