summaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2021-03-15 23:36:27 +0000
committerGo MAEDA <maeda@farend.jp>2021-03-15 23:36:27 +0000
commit1accf2a072bfa34b77162c29f42e556b8ec54056 (patch)
tree2c605d8282bf883980c7af4a312679a90e4cfa40 /app/models
parentc54349cc0b33dcc3f2a6a17661cc0d216e0e8736 (diff)
downloadredmine-1accf2a072bfa34b77162c29f42e556b8ec54056.tar.gz
redmine-1accf2a072bfa34b77162c29f42e556b8ec54056.zip
Delete spent time custom field values not visible by the user after assignment (#33550).
Patch by Marius BALTEANU. git-svn-id: http://svn.redmine.org/redmine/trunk@20802 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r--app/models/time_entry.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/app/models/time_entry.rb b/app/models/time_entry.rb
index ccf8b4461..1b0e18195 100644
--- a/app/models/time_entry.rb
+++ b/app/models/time_entry.rb
@@ -128,7 +128,14 @@ class TimeEntry < ActiveRecord::Base
else
@invalid_user_id = nil
end
+
+ # Delete assigned custom fields not visible by the user
+ editable_custom_field_ids = editable_custom_field_values(user).map {|v| v.custom_field_id.to_s}
+ self.custom_field_values.delete_if do |c|
+ !editable_custom_field_ids.include?(c.custom_field.id.to_s)
+ end
end
+
attrs
end
@@ -199,7 +206,7 @@ class TimeEntry < ActiveRecord::Base
# Returns the custom_field_values that can be edited by the given user
def editable_custom_field_values(user=nil)
- visible_custom_field_values
+ visible_custom_field_values(user)
end
# Returns the custom fields that can be edited by the given user