diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2020-04-05 08:21:25 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2020-04-05 08:21:25 +0000 |
commit | e91dbcb5a707db117f896ae099480b99b0805b00 (patch) | |
tree | 80417c2042d692efa983f9897f306c6b5502b4aa /app | |
parent | 214ec3e80655da61874fe0557849cfef8b063fdb (diff) | |
download | redmine-e91dbcb5a707db117f896ae099480b99b0805b00.tar.gz redmine-e91dbcb5a707db117f896ae099480b99b0805b00.zip |
Editing a time entry for a locked user changes the user to the current user (#32973).
Patch by Marius BALTEANU.
git-svn-id: http://svn.redmine.org/redmine/trunk@19651 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/timelog_helper.rb | 1 | ||||
-rw-r--r-- | app/models/time_entry.rb | 4 |
2 files changed, 4 insertions, 1 deletions
diff --git a/app/helpers/timelog_helper.rb b/app/helpers/timelog_helper.rb index fe5acb8f6..6fa0e0442 100644 --- a/app/helpers/timelog_helper.rb +++ b/app/helpers/timelog_helper.rb @@ -44,6 +44,7 @@ module TimelogHelper def user_collection_for_select_options(time_entry) collection = time_entry.assignable_users + collection << time_entry.user unless time_entry.user.nil? && !collection.include?(time_entry.user) principals_options_for_select(collection, time_entry.user_id.to_s) end diff --git a/app/models/time_entry.rb b/app/models/time_entry.rb index a763dc1be..e8ea1a88d 100644 --- a/app/models/time_entry.rb +++ b/app/models/time_entry.rb @@ -146,7 +146,9 @@ class TimeEntry < ActiveRecord::Base end end errors.add :project_id, :invalid if project.nil? - errors.add :user_id, :invalid if user_id != author_id && !self.assignable_users.map(&:id).include?(user_id) + if 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 errors.add :activity_id, :inclusion if activity_id_changed? && project && !project.activities.include?(activity) if spent_on_changed? && user |