diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2020-04-06 10:02:27 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2020-04-06 10:02:27 +0000 |
commit | b50b9ec5b3d6091b5c3ab51507004e079b538b70 (patch) | |
tree | 4e8da416077de8b67f801b5dfb82b457928d81c8 /app/models/time_entry.rb | |
parent | 6ccf502e95b39ca298d79cd2a502ae921c188bce (diff) | |
download | redmine-b50b9ec5b3d6091b5c3ab51507004e079b538b70.tar.gz redmine-b50b9ec5b3d6091b5c3ab51507004e079b538b70.zip |
Merged r19676 to r19678 to 4.1-stable (#32774).
git-svn-id: http://svn.redmine.org/redmine/branches/4.1-stable@19679 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/time_entry.rb')
-rw-r--r-- | app/models/time_entry.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/app/models/time_entry.rb b/app/models/time_entry.rb index 943613a82..1f3b0a7bf 100644 --- a/app/models/time_entry.rb +++ b/app/models/time_entry.rb @@ -50,6 +50,7 @@ class TimeEntry < ActiveRecord::Base validates_length_of :comments, :maximum => 1024, :allow_nil => true validates :spent_on, :date => true before_validation :set_project_if_nil + #TODO: remove this, author should be always explicitly set before_validation :set_author_if_nil validate :validate_time_entry @@ -116,6 +117,11 @@ class TimeEntry < ActiveRecord::Base @invalid_issue_id = issue_id end end + if user_id_changed? && user_id != author_id && !user.allowed_to?(:log_time_for_other_users, project) + @invalid_user_id = user_id + else + @invalid_user_id = nil + end end attrs end @@ -146,7 +152,7 @@ class TimeEntry < ActiveRecord::Base end end errors.add :project_id, :invalid if project.nil? - if user_id_changed? && user_id != author_id && !self.assignable_users.map(&:id).include?(user_id) + if @invalid_user_id || (user_id_changed? && user_id != author_id && !self.assignable_users.map(&:id).include?(user_id)) errors.add :user_id, :invalid end errors.add :issue_id, :invalid if (issue_id && !issue) || (issue && project!=issue.project) || @invalid_issue_id |