Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

add setting to enforce entering start and end times

Klaus Zandersf0559f7399c1
diff --git a/modules/costs/app/models/time_entry.rb b/modules/costs/app/models/time_entry.rb
index c4ea44097a1..ad9d0c005b6 100644
--- a/modules/costs/app/models/time_entry.rb
+++ b/modules/costs/app/models/time_entry.rb
@@ -101,11 +101,17 @@ class TimeEntry < ApplicationRecord
(user_id == usr.id && usr.allowed_in_project?(:view_own_hourly_rate, project))
end
- def self.can_track_start_and_end_time?(_project: nil)
- OpenProject::FeatureDecisions.track_start_and_end_times_for_time_entries_active? &&
- Setting.allow_tracking_start_and_end_times
+ class << self
+ def can_track_start_and_end_time?(_project: nil)
+ OpenProject::FeatureDecisions.track_start_and_end_times_for_time_entries_active? &&
+ Setting.allow_tracking_start_and_end_times?
+ # TODO: Add project check when we have decided if we also want a project specific flag
+ end
- # TODO: Add project check when we have decided if we also want a project specific flag
+ def must_track_start_and_end_time?(_project: nil)
+ can_track_start_and_end_time? && Setting.enforce_tracking_start_and_end_times?
+ # TODO: Add project check when we have decided if we also want a project specific flag
+ end
end
private
diff --git a/modules/costs/lib/costs/engine.rb b/modules/costs/lib/costs/engine.rb
index 7963f2c7095..553062b1338 100644
--- a/modules/costs/lib/costs/engine.rb
+++ b/modules/costs/lib/costs/engine.rb
@@ -143,6 +143,7 @@ module Costs
::Settings::Definition.add "costs_currency", default: "EUR", format: :string
::Settings::Definition.add "costs_currency_format", default: "%n %u", format: :string
::Settings::Definition.add "allow_tracking_start_and_end_times", default: false, format: :boolean
+ ::Settings::Definition.add "enforce_tracking_start_and_end_times", default: false, format: :boolean
end
initializer "costs.feature_decisions" do