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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Add a validation to not enable enforcement without allowing
Klaus Zanders15f337c52931
diff --git a/modules/costs/app/controllers/admin/costs_settings_controller.rb b/modules/costs/app/controllers/admin/costs_settings_controller.rbindex 9d8ff23ce6a..f43ba4127e8 100644--- a/modules/costs/app/controllers/admin/costs_settings_controller.rb+++ b/modules/costs/app/controllers/admin/costs_settings_controller.rb@@ -30,5 +30,24 @@module Adminclass CostsSettingsController < SettingsControllermenu_item :costs_settings++ before_action :validate_times_enabled_for_enforcement, only: :update++ def update # rubocop:disable Lint/UselessMethodDefinition+ super+ end++ private++ def validate_times_enabled_for_enforcement+ pp(settings_params)+ allow_times = ActiveRecord::Type::Boolean.new.cast(settings_params[:allow_tracking_start_and_end_times])+ force_times = ActiveRecord::Type::Boolean.new.cast(settings_params[:enforce_tracking_start_and_end_times])++ if force_times && !allow_times+ flash[:error] = I18n.t("setting_enforce_without_allow")+ redirect_to action: :show+ end+ endendenddiff --git a/modules/costs/config/locales/en.yml b/modules/costs/config/locales/en.ymlindex 4fbf2557b88..5fed849789e 100644--- a/modules/costs/config/locales/en.yml+++ b/modules/costs/config/locales/en.yml@@ -216,6 +216,7 @@ en:setting_costs_currency: "Currency"setting_costs_currency_format: "Format of currency"setting_enforce_tracking_start_and_end_times: "Require exact times"+ setting_enforce_without_allow: "Requiring exact times is not possible without allowing them"text_assign_time_and_cost_entries_to_project: "Assign reported hours and costs to the project"text_destroy_cost_entries_question: "%{cost_entries} were reported on the work packages you are about to delete. What do you want to do ?"