diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-04-12 07:37:18 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-04-12 07:37:18 +0000 |
commit | 3d1c40cd525feebb0818a29c0940d45ae58203b9 (patch) | |
tree | 5172fe6fbcdaa5f655771c15be7096c53981ae0b /app/models/time_entry.rb | |
parent | 8c6e5513a1c1748f0768944822cc607ed93fd24c (diff) | |
download | redmine-3d1c40cd525feebb0818a29c0940d45ae58203b9.tar.gz redmine-3d1c40cd525feebb0818a29c0940d45ae58203b9.zip |
Fixed validation when logging time on issue (#19464).
git-svn-id: http://svn.redmine.org/redmine/trunk@14162 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/time_entry.rb')
-rw-r--r-- | app/models/time_entry.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/app/models/time_entry.rb b/app/models/time_entry.rb index f66fbc78a..87d27c1de 100644 --- a/app/models/time_entry.rb +++ b/app/models/time_entry.rb @@ -68,9 +68,14 @@ class TimeEntry < ActiveRecord::Base def safe_attributes=(attrs, user=User.current) if attrs attrs = super(attrs) - if issue_id_changed? && attrs[:project_id].blank? && issue && issue.project_id != project_id + if issue_id_changed? && issue if user.allowed_to?(:log_time, issue.project) - self.project_id = issue.project_id + if attrs[:project_id].blank? && issue.project_id != project_id + self.project_id = issue.project_id + end + @invalid_issue_id = nil + else + @invalid_issue_id = issue_id end end end @@ -84,7 +89,7 @@ class TimeEntry < ActiveRecord::Base def validate_time_entry errors.add :hours, :invalid if hours && (hours < 0 || hours >= 1000) errors.add :project_id, :invalid if project.nil? - errors.add :issue_id, :invalid if (issue_id && !issue) || (issue && project!=issue.project) + errors.add :issue_id, :invalid if (issue_id && !issue) || (issue && project!=issue.project) || @invalid_issue_id end def hours=(h) |