summaryrefslogtreecommitdiffstats
path: root/app/models/time_entry_import.rb
diff options
context:
space:
mode:
authorMarius Balteanu <marius.balteanu@zitec.com>2022-04-03 07:54:27 +0000
committerMarius Balteanu <marius.balteanu@zitec.com>2022-04-03 07:54:27 +0000
commit5914b0ebc29ad050a41c8e3147f4894b2b33cc23 (patch)
tree2cb97e139c63a5867c6329c3f611e1f93d7544db /app/models/time_entry_import.rb
parentb1e4411c497161eca7a977db5243ff92bff88d82 (diff)
downloadredmine-5914b0ebc29ad050a41c8e3147f4894b2b33cc23.tar.gz
redmine-5914b0ebc29ad050a41c8e3147f4894b2b33cc23.zip
Allow imported time entries to override the selected project with the actual project of their issue (#36823).
Patch by Jens Krämer. git-svn-id: https://svn.redmine.org/redmine/trunk@21522 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/time_entry_import.rb')
-rw-r--r--app/models/time_entry_import.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/app/models/time_entry_import.rb b/app/models/time_entry_import.rb
index 27b9e040f..3f4fdbbc6 100644
--- a/app/models/time_entry_import.rb
+++ b/app/models/time_entry_import.rb
@@ -105,17 +105,21 @@ class TimeEntryImport < Import
end
attributes = {
- :project_id => project.id,
:activity_id => activity_id,
:author_id => user.id,
:user_id => user_id,
- :issue_id => row_value(row, 'issue_id'),
:spent_on => row_date(row, 'spent_on'),
:hours => row_value(row, 'hours'),
:comments => row_value(row, 'comments')
}
+ if issue_id = row_value(row, 'issue_id').presence
+ attributes[:issue_id] = issue_id
+ else
+ attributes[:project_id] = project.id
+ end
+
attributes['custom_field_values'] = object.custom_field_values.inject({}) do |h, v|
value =
case v.custom_field.field_format