summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2015-03-01 13:23:52 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2015-03-01 13:23:52 +0000
commit8667505e23b99d5ed025f9f26d87f41eb4c64aa0 (patch)
tree99fd944fa48849e4a2ea43e87c9612b1c422c038 /app
parentdbe05a000ab0072529d95eddd89e33cbd5fa97ec (diff)
downloadredmine-8667505e23b99d5ed025f9f26d87f41eb4c64aa0.tar.gz
redmine-8667505e23b99d5ed025f9f26d87f41eb4c64aa0.zip
Don't validate custom fields that are not editable (#19193).
git-svn-id: http://svn.redmine.org/redmine/trunk@14045 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/models/issue.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb
index 5a49b0d7b..dcc3930a5 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -640,6 +640,17 @@ class Issue < 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 = new_record? ? author : current_journal.try(:user)
+ if new_record? || custom_field_values_changed?
+ editable_custom_field_values(user).each(&:validate_value)
+ end
+ end
+
# Set the done_ratio using the status if that setting is set. This will keep the done_ratios
# even if the user turns off the setting later
def update_done_ratio_from_issue_status