Mercurial > hg > soundsoftware-site
comparison app/models/project.rb @ 929:5f33065ddc4b redmine-1.3
Update to Redmine SVN rev 9414 on 1.3-stable branch
author | Chris Cannam |
---|---|
date | Wed, 27 Jun 2012 14:54:18 +0100 |
parents | cbb26bc654de |
children | ec1c49528f36 433d4f72a19b |
comparison
equal
deleted
inserted
replaced
909:cbb26bc654de | 929:5f33065ddc4b |
---|---|
251 end | 251 end |
252 end | 252 end |
253 | 253 |
254 def to_param | 254 def to_param |
255 # id is used for projects with a numeric identifier (compatibility) | 255 # id is used for projects with a numeric identifier (compatibility) |
256 @to_param ||= (identifier.to_s =~ %r{^\d*$} ? id : identifier) | 256 @to_param ||= (identifier.to_s =~ %r{^\d*$} ? id.to_s : identifier) |
257 end | 257 end |
258 | 258 |
259 def active? | 259 def active? |
260 self.status == STATUS_ACTIVE | 260 self.status == STATUS_ACTIVE |
261 end | 261 end |
388 :conditions => ["#{Project.table_name}.lft >= ? AND #{Project.table_name}.rgt <= ? AND #{Project.table_name}.status = #{STATUS_ACTIVE}", lft, rgt]) | 388 :conditions => ["#{Project.table_name}.lft >= ? AND #{Project.table_name}.rgt <= ? AND #{Project.table_name}.status = #{STATUS_ACTIVE}", lft, rgt]) |
389 end | 389 end |
390 | 390 |
391 # Returns a scope of the Versions used by the project | 391 # Returns a scope of the Versions used by the project |
392 def shared_versions | 392 def shared_versions |
393 @shared_versions ||= begin | 393 if new_record? |
394 r = root? ? self : root | |
395 Version.scoped(:include => :project, | 394 Version.scoped(:include => :project, |
396 :conditions => "#{Project.table_name}.id = #{id}" + | 395 :conditions => "#{Project.table_name}.status = #{Project::STATUS_ACTIVE} AND #{Version.table_name}.sharing = 'system'") |
397 " OR (#{Project.table_name}.status = #{Project::STATUS_ACTIVE} AND (" + | 396 else |
397 @shared_versions ||= begin | |
398 r = root? ? self : root | |
399 Version.scoped(:include => :project, | |
400 :conditions => "#{Project.table_name}.id = #{id}" + | |
401 " OR (#{Project.table_name}.status = #{Project::STATUS_ACTIVE} AND (" + | |
398 " #{Version.table_name}.sharing = 'system'" + | 402 " #{Version.table_name}.sharing = 'system'" + |
399 " OR (#{Project.table_name}.lft >= #{r.lft} AND #{Project.table_name}.rgt <= #{r.rgt} AND #{Version.table_name}.sharing = 'tree')" + | 403 " OR (#{Project.table_name}.lft >= #{r.lft} AND #{Project.table_name}.rgt <= #{r.rgt} AND #{Version.table_name}.sharing = 'tree')" + |
400 " OR (#{Project.table_name}.lft < #{lft} AND #{Project.table_name}.rgt > #{rgt} AND #{Version.table_name}.sharing IN ('hierarchy', 'descendants'))" + | 404 " OR (#{Project.table_name}.lft < #{lft} AND #{Project.table_name}.rgt > #{rgt} AND #{Version.table_name}.sharing IN ('hierarchy', 'descendants'))" + |
401 " OR (#{Project.table_name}.lft > #{lft} AND #{Project.table_name}.rgt < #{rgt} AND #{Version.table_name}.sharing = 'hierarchy')" + | 405 " OR (#{Project.table_name}.lft > #{lft} AND #{Project.table_name}.rgt < #{rgt} AND #{Version.table_name}.sharing = 'hierarchy')" + |
402 "))") | 406 "))") |
407 end | |
403 end | 408 end |
404 end | 409 end |
405 | 410 |
406 # Returns a hash of project users grouped by role | 411 # Returns a hash of project users grouped by role |
407 def users_by_role | 412 def users_by_role |