diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-10-04 07:23:14 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-10-04 07:23:14 +0000 |
commit | 15d5c331ebc15caee6d8acf89d81b506102c8fa4 (patch) | |
tree | 3cf842a10d3b7f580f23fbd2a1b6f3357271f3b9 /app/models/time_entry.rb | |
parent | 1232f0670e2002d010d29bb804fa769783314065 (diff) | |
download | redmine-15d5c331ebc15caee6d8acf89d81b506102c8fa4.tar.gz redmine-15d5c331ebc15caee6d8acf89d81b506102c8fa4.zip |
Let the new time_entry form be submitted without project (#17954).
git-svn-id: http://svn.redmine.org/redmine/trunk@13422 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/time_entry.rb')
-rw-r--r-- | app/models/time_entry.rb | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/app/models/time_entry.rb b/app/models/time_entry.rb index 103d5ae62..662070840 100644 --- a/app/models/time_entry.rb +++ b/app/models/time_entry.rb @@ -24,7 +24,7 @@ class TimeEntry < ActiveRecord::Base belongs_to :user belongs_to :activity, :class_name => 'TimeEntryActivity', :foreign_key => 'activity_id' - attr_protected :project_id, :user_id, :tyear, :tmonth, :tweek + attr_protected :user_id, :tyear, :tmonth, :tweek acts_as_customizable acts_as_event :title => Proc.new {|o| "#{l_hours(o.hours)} (#{(o.issue || o.project).event_title})"}, @@ -65,7 +65,7 @@ class TimeEntry < ActiveRecord::Base end } - safe_attributes 'hours', 'comments', 'issue_id', 'activity_id', 'spent_on', 'custom_field_values', 'custom_fields' + safe_attributes 'hours', 'comments', 'project_id', 'issue_id', 'activity_id', 'spent_on', 'custom_field_values', 'custom_fields' def initialize(attributes=nil, *args) super @@ -78,10 +78,12 @@ class TimeEntry < ActiveRecord::Base 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 + if attrs + attrs = super(attrs) + if issue_id_changed? && attrs[:project_id].blank? && issue && issue.project_id != project_id + if user.allowed_to?(:log_time, issue.project) + self.project_id = issue.project_id + end end end attrs |