diff options
author | Marius Balteanu <marius.balteanu@zitec.com> | 2022-03-21 22:13:19 +0000 |
---|---|---|
committer | Marius Balteanu <marius.balteanu@zitec.com> | 2022-03-21 22:13:19 +0000 |
commit | 81575e7291adee92ecaa0757c1859d66506c66bf (patch) | |
tree | 89ff4560a1f41cabaccd89048c99f9d25a4015dc /app/models | |
parent | 72bebd1d45664f66405aa0717a3da09878628dae (diff) | |
download | redmine-81575e7291adee92ecaa0757c1859d66506c66bf.tar.gz redmine-81575e7291adee92ecaa0757c1859d66506c66bf.zip |
Skip validation of required custom fields when creating a project if user does not have permissions to see those custom fields (#36593).
Patch by mathieu-mbru.
git-svn-id: https://svn.redmine.org/redmine/trunk@21488 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/project.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 90ef0e2e9..7ba9b4197 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -963,6 +963,17 @@ class Project < ActiveRecord::Base end end + # Overrides Redmine::Acts::Customizable::InstanceMethods#validate_custom_field_values + # so that custom values that are not editable are not validated (eg. a custom field that + # is marked as required should not trigger a validation error if the user is not allowed + # to edit this field). + def validate_custom_field_values + user = User.current + if new_record? || custom_field_values_changed? + editable_custom_field_values(user).each(&:validate_value) + end + end + # Returns the custom_field_values that can be edited by the given user def editable_custom_field_values(user=nil) visible_custom_field_values(user) |