Mercurial > hg > soundsoftware-site
comparison app/models/project.rb @ 931:ec1c49528f36 cannam_integration
Merge from branch "redmine-1.3"
author | Chris Cannam |
---|---|
date | Wed, 27 Jun 2012 15:04:58 +0100 |
parents | b502ad91d302 5f33065ddc4b |
children | bb32da3bea34 2101a7c906b3 |
comparison
equal
deleted
inserted
replaced
930:027cc0f5d4a2 | 931:ec1c49528f36 |
---|---|
256 end | 256 end |
257 end | 257 end |
258 | 258 |
259 def to_param | 259 def to_param |
260 # id is used for projects with a numeric identifier (compatibility) | 260 # id is used for projects with a numeric identifier (compatibility) |
261 @to_param ||= (identifier.to_s =~ %r{^\d*$} ? id : identifier) | 261 @to_param ||= (identifier.to_s =~ %r{^\d*$} ? id.to_s : identifier) |
262 end | 262 end |
263 | 263 |
264 def active? | 264 def active? |
265 self.status == STATUS_ACTIVE | 265 self.status == STATUS_ACTIVE |
266 end | 266 end |
393 :conditions => ["#{Project.table_name}.lft >= ? AND #{Project.table_name}.rgt <= ? AND #{Project.table_name}.status = #{STATUS_ACTIVE}", lft, rgt]) | 393 :conditions => ["#{Project.table_name}.lft >= ? AND #{Project.table_name}.rgt <= ? AND #{Project.table_name}.status = #{STATUS_ACTIVE}", lft, rgt]) |
394 end | 394 end |
395 | 395 |
396 # Returns a scope of the Versions used by the project | 396 # Returns a scope of the Versions used by the project |
397 def shared_versions | 397 def shared_versions |
398 @shared_versions ||= begin | 398 if new_record? |
399 r = root? ? self : root | |
400 Version.scoped(:include => :project, | 399 Version.scoped(:include => :project, |
401 :conditions => "#{Project.table_name}.id = #{id}" + | 400 :conditions => "#{Project.table_name}.status = #{Project::STATUS_ACTIVE} AND #{Version.table_name}.sharing = 'system'") |
402 " OR (#{Project.table_name}.status = #{Project::STATUS_ACTIVE} AND (" + | 401 else |
402 @shared_versions ||= begin | |
403 r = root? ? self : root | |
404 Version.scoped(:include => :project, | |
405 :conditions => "#{Project.table_name}.id = #{id}" + | |
406 " OR (#{Project.table_name}.status = #{Project::STATUS_ACTIVE} AND (" + | |
403 " #{Version.table_name}.sharing = 'system'" + | 407 " #{Version.table_name}.sharing = 'system'" + |
404 " OR (#{Project.table_name}.lft >= #{r.lft} AND #{Project.table_name}.rgt <= #{r.rgt} AND #{Version.table_name}.sharing = 'tree')" + | 408 " OR (#{Project.table_name}.lft >= #{r.lft} AND #{Project.table_name}.rgt <= #{r.rgt} AND #{Version.table_name}.sharing = 'tree')" + |
405 " OR (#{Project.table_name}.lft < #{lft} AND #{Project.table_name}.rgt > #{rgt} AND #{Version.table_name}.sharing IN ('hierarchy', 'descendants'))" + | 409 " OR (#{Project.table_name}.lft < #{lft} AND #{Project.table_name}.rgt > #{rgt} AND #{Version.table_name}.sharing IN ('hierarchy', 'descendants'))" + |
406 " OR (#{Project.table_name}.lft > #{lft} AND #{Project.table_name}.rgt < #{rgt} AND #{Version.table_name}.sharing = 'hierarchy')" + | 410 " OR (#{Project.table_name}.lft > #{lft} AND #{Project.table_name}.rgt < #{rgt} AND #{Version.table_name}.sharing = 'hierarchy')" + |
407 "))") | 411 "))") |
412 end | |
408 end | 413 end |
409 end | 414 end |
410 | 415 |
411 # Returns a hash of project users grouped by role | 416 # Returns a hash of project users grouped by role |
412 def users_by_role | 417 def users_by_role |