From 4b0ac7a78b31a409f51814303d6b40ecf24801a3 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 5 Apr 2020 09:47:00 +0000 Subject: Merged r19651 and r19652 to 4.1-stable (#32973). git-svn-id: http://svn.redmine.org/redmine/branches/4.1-stable@19657 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/timelog_helper.rb | 1 + app/models/time_entry.rb | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/helpers/timelog_helper.rb b/app/helpers/timelog_helper.rb index e0cc51d27..f8f36fbdd 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 38359294d..943613a82 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 -- cgit v1.2.3