diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-02-13 18:57:12 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-02-13 18:57:12 +0000 |
commit | cccfed7006f11e34902c2863053e29317807b453 (patch) | |
tree | 9d89be2530f62fdf5e48bc5899680709d12bf2cf /app | |
parent | 7fa18cad5771ea63cb1c55a24ade75a573af5dae (diff) | |
download | redmine-cccfed7006f11e34902c2863053e29317807b453.tar.gz redmine-cccfed7006f11e34902c2863053e29317807b453.zip |
Fixed: error when creating a project with a version format custom field (#10218).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8865 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/models/project.rb | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 407f723c4..997ed4615 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -411,16 +411,21 @@ class Project < ActiveRecord::Base # Returns a scope of the Versions used by the project def shared_versions - @shared_versions ||= begin - r = root? ? self : root + if new_record? Version.scoped(:include => :project, - :conditions => "#{Project.table_name}.id = #{id}" + - " OR (#{Project.table_name}.status = #{Project::STATUS_ACTIVE} AND (" + + :conditions => "#{Project.table_name}.status = #{Project::STATUS_ACTIVE} AND #{Version.table_name}.sharing = 'system'") + else + @shared_versions ||= begin + r = root? ? self : root + Version.scoped(:include => :project, + :conditions => "#{Project.table_name}.id = #{id}" + + " OR (#{Project.table_name}.status = #{Project::STATUS_ACTIVE} AND (" + " #{Version.table_name}.sharing = 'system'" + " OR (#{Project.table_name}.lft >= #{r.lft} AND #{Project.table_name}.rgt <= #{r.rgt} AND #{Version.table_name}.sharing = 'tree')" + " OR (#{Project.table_name}.lft < #{lft} AND #{Project.table_name}.rgt > #{rgt} AND #{Version.table_name}.sharing IN ('hierarchy', 'descendants'))" + " OR (#{Project.table_name}.lft > #{lft} AND #{Project.table_name}.rgt < #{rgt} AND #{Version.table_name}.sharing = 'hierarchy')" + "))") + end end end |