diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-10-01 09:06:17 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-10-01 09:06:17 +0000 |
commit | d478785aeacd65e40570b1cd4513864efa5fbac4 (patch) | |
tree | 3156328304f6145593885a21f4d924b323bfb8cd /app | |
parent | 84ab16dcfe2866adedef428bbcc8e68bfb8efc20 (diff) | |
download | redmine-d478785aeacd65e40570b1cd4513864efa5fbac4.tar.gz redmine-d478785aeacd65e40570b1cd4513864efa5fbac4.zip |
Let the API accept project identifier for creating issues (#23766).
Patch by Holger Just.
git-svn-id: http://svn.redmine.org/redmine/trunk@15855 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/models/issue.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb index d550616a9..e2699394b 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -502,8 +502,13 @@ class Issue < ActiveRecord::Base # Project and Tracker must be set before since new_statuses_allowed_to depends on it. if (p = attrs.delete('project_id')) && safe_attribute?('project_id') - if allowed_target_projects(user).where(:id => p.to_i).exists? - self.project_id = p + if p.is_a?(String) && !p.match(/^\d*$/) + p_id = Project.find_by_identifier(p).try(:id) + else + p_id = p.to_i + end + if allowed_target_projects(user).where(:id => p_id).exists? + self.project_id = p_id end if project_id_changed? && attrs['category_id'].to_s == category_id_was.to_s |