本站源代码
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.

45 lines
1.7KB

  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 models
  5. import "code.gitea.io/gitea/modules/setting"
  6. // ___________.__ ___________ __
  7. // \__ ___/|__| _____ ___\__ ___/___________ ____ | | __ ___________
  8. // | | | |/ \_/ __ \| | \_ __ \__ \ _/ ___\| |/ // __ \_ __ \
  9. // | | | | Y Y \ ___/| | | | \// __ \\ \___| <\ ___/| | \/
  10. // |____| |__|__|_| /\___ >____| |__| (____ /\___ >__|_ \\___ >__|
  11. // \/ \/ \/ \/ \/ \/
  12. // CanEnableTimetracker returns true when the server admin enabled time tracking
  13. // This overrules IsTimetrackerEnabled
  14. func (repo *Repository) CanEnableTimetracker() bool {
  15. return setting.Service.EnableTimetracking
  16. }
  17. // IsTimetrackerEnabled returns whether or not the timetracker is enabled. It returns the default value from config if an error occurs.
  18. func (repo *Repository) IsTimetrackerEnabled() bool {
  19. if !setting.Service.EnableTimetracking {
  20. return false
  21. }
  22. var u *RepoUnit
  23. var err error
  24. if u, err = repo.GetUnit(UnitTypeIssues); err != nil {
  25. return setting.Service.DefaultEnableTimetracking
  26. }
  27. return u.IssuesConfig().EnableTimetracker
  28. }
  29. // AllowOnlyContributorsToTrackTime returns value of IssuesConfig or the default value
  30. func (repo *Repository) AllowOnlyContributorsToTrackTime() bool {
  31. var u *RepoUnit
  32. var err error
  33. if u, err = repo.GetUnit(UnitTypeIssues); err != nil {
  34. return setting.Service.DefaultAllowOnlyContributorsToTrackTime
  35. }
  36. return u.IssuesConfig().AllowOnlyContributorsToTrackTime
  37. }
上海开阖软件有限公司 沪ICP备12045867号-1