summaryrefslogtreecommitdiffstats
path: root/app/models/time_entry.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2014-03-21 02:12:32 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2014-03-21 02:12:32 +0000
commitdd70327ce4d11d21382f1c9ac7de4c64c7f0bb7f (patch)
treec16aed3429ce717ae15cbf4b9f7987ee15a71af4 /app/models/time_entry.rb
parent273aa42900a0cd67ab60cc59217528362425f1f1 (diff)
downloadredmine-dd70327ce4d11d21382f1c9ac7de4c64c7f0bb7f.tar.gz
redmine-dd70327ce4d11d21382f1c9ac7de4c64c7f0bb7f.zip
Let user choose an issue of another project when updating a time entry (#16338).
git-svn-id: http://svn.redmine.org/redmine/trunk@12990 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/time_entry.rb')
-rw-r--r--app/models/time_entry.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/models/time_entry.rb b/app/models/time_entry.rb
index 5c1c7b67a..cfca47639 100644
--- a/app/models/time_entry.rb
+++ b/app/models/time_entry.rb
@@ -77,6 +77,16 @@ class TimeEntry < ActiveRecord::Base
end
end
+ def safe_attributes=(attrs, user=User.current)
+ attrs = super
+ if !new_record? && issue && issue.project_id != project_id
+ if user.allowed_to?(:log_time, issue.project)
+ self.project_id = issue.project_id
+ end
+ end
+ attrs
+ end
+
def set_project_if_nil
self.project = issue.project if issue && project.nil?
end