Feature #594 » subproject_no_level.diff
| redmine/app/controllers/projects_controller.rb 2008-09-11 08:57:41.546391600 +0200 | ||
|---|---|---|
|
@issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
|
||
|
@trackers = Tracker.all
|
||
|
@root_projects = Project.find(:all,
|
||
|
:conditions => "parent_id IS NULL AND status = #{Project::STATUS_ACTIVE}",
|
||
|
:conditions => "status = #{Project::STATUS_ACTIVE}",
|
||
|
:order => 'name')
|
||
|
if @project != nil
|
||
|
@root_projects = @root_projects - @project.fetch_all_subprojects_id_recursively()
|
||
|
end
|
||
|
@project = Project.new(params[:project])
|
||
|
if request.get?
|
||
|
@project.identifier = Project.next_identifier if Setting.sequential_project_identifiers?
|
||
| ... | ... | |
|
|
||
|
def settings
|
||
|
@root_projects = Project.find(:all,
|
||
|
:conditions => ["parent_id IS NULL AND status = #{Project::STATUS_ACTIVE} AND id <> ?", @project.id],
|
||
|
:conditions => ["status = #{Project::STATUS_ACTIVE} AND id <> ?", @project.id],
|
||
|
:order => 'name')
|
||
|
if @project != nil
|
||
|
@root_projects = @root_projects - @project.fetch_all_subprojects_id_recursively()
|
||
|
end
|
||
|
@issue_custom_fields = IssueCustomField.find(:all, :order => "#{CustomField.table_name}.position")
|
||
|
@issue_category ||= IssueCategory.new
|
||
|
@member ||= @project.members.new
|
||
| redmine/app/models/project.rb 2008-09-11 16:27:18.421875000 +0200 | ||
|---|---|---|
|
errors[:identifier].nil? && !(new_record? || identifier.blank?)
|
||
|
end
|
||
|
|
||
|
def fetch_all_subprojects_recursively
|
||
|
ret = Array.new
|
||
|
if self.children.size > 0
|
||
|
self.children.each { |subproject|
|
||
|
ret << subproject
|
||
|
ret += subproject.fetch_all_subprojects_recursively()
|
||
|
}
|
||
|
end
|
||
|
return ret
|
||
|
end
|
||
|
|
||
|
def fetch_all_subprojects_id_recursively
|
||
|
ret = Array.new
|
||
|
if self.children.size > 0
|
||
|
self.children.each { |subproject|
|
||
|
ret << subproject.id.to_s
|
||
|
ret += subproject.fetch_all_subprojects_id_recursively()
|
||
|
}
|
||
|
end
|
||
|
return ret
|
||
|
end
|
||
|
|
||
|
def issues_with_subprojects(include_subprojects=false)
|
||
|
conditions = nil
|
||
|
if include_subprojects
|
||
|
ids = [id] + child_ids
|
||
|
ids = [id] + fetch_all_subprojects_id_recursively()
|
||
|
conditions = ["#{Project.table_name}.id IN (#{ids.join(',')}) AND #{Project.visible_by}"]
|
||
|
end
|
||
|
conditions ||= ["#{Project.table_name}.id = ?", id]
|
||
| ... | ... | |
|
|
||
|
protected
|
||
|
def validate
|
||
|
errors.add(parent_id, " must be a root project") if parent and parent.parent
|
||
|
errors.add_to_base("A project with subprojects can't be a subproject") if parent and children.size > 0
|
||
|
errors.add(:identifier, :activerecord_error_invalid) if !identifier.blank? && identifier.match(/^\d*$/)
|
||
|
end
|
||
|
|
||
| redmine/app/models/query.rb 2008-09-11 08:52:04.204289400 +0200 | ||
|---|---|---|
|
# main project only
|
||
|
else
|
||
|
# all subprojects
|
||
|
ids += project.child_ids
|
||
|
ids += project.fetch_all_subprojects_id_recursively()
|
||
|
end
|
||
|
elsif Setting.display_subprojects_issues?
|
||
|
ids += project.child_ids
|
||
|
ids += project.fetch_all_subprojects_id_recursively()
|
||
|
end
|
||
|
project_clauses << "#{Issue.table_name}.project_id IN (%s)" % ids.join(',')
|
||
|
elsif project
|
||