On the calendar, the gantt and in the Tracker filter on the issue list, only active trackers of the project (and its sub projects) can be selected.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1071 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
18066ba8bf
commit
049051103b
|
@ -418,7 +418,7 @@ class ProjectsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def calendar
|
def calendar
|
||||||
@trackers = Tracker.find(:all, :order => 'position')
|
@trackers = @project.rolled_up_trackers
|
||||||
retrieve_selected_tracker_ids(@trackers)
|
retrieve_selected_tracker_ids(@trackers)
|
||||||
|
|
||||||
if params[:year] and params[:year].to_i > 1900
|
if params[:year] and params[:year].to_i > 1900
|
||||||
|
@ -445,7 +445,7 @@ class ProjectsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def gantt
|
def gantt
|
||||||
@trackers = Tracker.find(:all, :order => 'position')
|
@trackers = @project.rolled_up_trackers
|
||||||
retrieve_selected_tracker_ids(@trackers)
|
retrieve_selected_tracker_ids(@trackers)
|
||||||
|
|
||||||
if params[:year] and params[:year].to_i >0
|
if params[:year] and params[:year].to_i >0
|
||||||
|
|
|
@ -146,6 +146,15 @@ class Project < ActiveRecord::Base
|
||||||
children.select {|child| child.active?}
|
children.select {|child| child.active?}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns an array of the trackers used by the project and its sub projects
|
||||||
|
def rolled_up_trackers
|
||||||
|
@rolled_up_trackers ||=
|
||||||
|
Tracker.find(:all, :include => :projects,
|
||||||
|
:select => "DISTINCT #{Tracker.table_name}.*",
|
||||||
|
:conditions => ["#{Project.table_name}.id = ? OR #{Project.table_name}.parent_id = ?", id, id],
|
||||||
|
:order => "#{Tracker.table_name}.position")
|
||||||
|
end
|
||||||
|
|
||||||
# Deletes all project's members
|
# Deletes all project's members
|
||||||
def delete_all_members
|
def delete_all_members
|
||||||
Member.delete_all(['project_id = ?', id])
|
Member.delete_all(['project_id = ?', id])
|
||||||
|
|
|
@ -132,8 +132,11 @@ class Query < ActiveRecord::Base
|
||||||
|
|
||||||
def available_filters
|
def available_filters
|
||||||
return @available_filters if @available_filters
|
return @available_filters if @available_filters
|
||||||
|
|
||||||
|
trackers = project.nil? ? Tracker.find(:all, :order => 'position') : project.rolled_up_trackers
|
||||||
|
|
||||||
@available_filters = { "status_id" => { :type => :list_status, :order => 1, :values => IssueStatus.find(:all, :order => 'position').collect{|s| [s.name, s.id.to_s] } },
|
@available_filters = { "status_id" => { :type => :list_status, :order => 1, :values => IssueStatus.find(:all, :order => 'position').collect{|s| [s.name, s.id.to_s] } },
|
||||||
"tracker_id" => { :type => :list, :order => 2, :values => Tracker.find(:all, :order => 'position').collect{|s| [s.name, s.id.to_s] } },
|
"tracker_id" => { :type => :list, :order => 2, :values => trackers.collect{|s| [s.name, s.id.to_s] } },
|
||||||
"priority_id" => { :type => :list, :order => 3, :values => Enumeration.find(:all, :conditions => ['opt=?','IPRI']).collect{|s| [s.name, s.id.to_s] } },
|
"priority_id" => { :type => :list, :order => 3, :values => Enumeration.find(:all, :conditions => ['opt=?','IPRI']).collect{|s| [s.name, s.id.to_s] } },
|
||||||
"subject" => { :type => :text, :order => 8 },
|
"subject" => { :type => :text, :order => 8 },
|
||||||
"created_on" => { :type => :date_past, :order => 9 },
|
"created_on" => { :type => :date_past, :order => 9 },
|
||||||
|
|
|
@ -19,6 +19,7 @@ class Tracker < ActiveRecord::Base
|
||||||
before_destroy :check_integrity
|
before_destroy :check_integrity
|
||||||
has_many :issues
|
has_many :issues
|
||||||
has_many :workflows, :dependent => :delete_all
|
has_many :workflows, :dependent => :delete_all
|
||||||
|
has_and_belongs_to_many :projects
|
||||||
has_and_belongs_to_many :custom_fields, :class_name => 'IssueCustomField', :join_table => "#{table_name_prefix}custom_fields_trackers#{table_name_suffix}", :association_foreign_key => 'custom_field_id'
|
has_and_belongs_to_many :custom_fields, :class_name => 'IssueCustomField', :join_table => "#{table_name_prefix}custom_fields_trackers#{table_name_suffix}", :association_foreign_key => 'custom_field_id'
|
||||||
acts_as_list
|
acts_as_list
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,6 @@ projects_trackers_002:
|
||||||
projects_trackers_014:
|
projects_trackers_014:
|
||||||
project_id: 5
|
project_id: 5
|
||||||
tracker_id: 2
|
tracker_id: 2
|
||||||
projects_trackers_003:
|
|
||||||
project_id: 1
|
|
||||||
tracker_id: 3
|
|
||||||
projects_trackers_015:
|
projects_trackers_015:
|
||||||
project_id: 5
|
project_id: 5
|
||||||
tracker_id: 3
|
tracker_id: 3
|
||||||
|
@ -29,9 +26,6 @@ projects_trackers_005:
|
||||||
projects_trackers_006:
|
projects_trackers_006:
|
||||||
project_id: 2
|
project_id: 2
|
||||||
tracker_id: 3
|
tracker_id: 3
|
||||||
projects_trackers_007:
|
|
||||||
project_id: 3
|
|
||||||
tracker_id: 1
|
|
||||||
projects_trackers_008:
|
projects_trackers_008:
|
||||||
project_id: 3
|
project_id: 3
|
||||||
tracker_id: 2
|
tracker_id: 2
|
||||||
|
|
|
@ -3,11 +3,14 @@ trackers_001:
|
||||||
name: Bug
|
name: Bug
|
||||||
id: 1
|
id: 1
|
||||||
is_in_chlog: true
|
is_in_chlog: true
|
||||||
|
position: 1
|
||||||
trackers_002:
|
trackers_002:
|
||||||
name: Feature request
|
name: Feature request
|
||||||
id: 2
|
id: 2
|
||||||
is_in_chlog: true
|
is_in_chlog: true
|
||||||
|
position: 2
|
||||||
trackers_003:
|
trackers_003:
|
||||||
name: Support request
|
name: Support request
|
||||||
id: 3
|
id: 3
|
||||||
is_in_chlog: false
|
is_in_chlog: false
|
||||||
|
position: 3
|
||||||
|
|
|
@ -112,10 +112,10 @@ class ProjectsControllerTest < Test::Unit::TestCase
|
||||||
|
|
||||||
def test_move_issues_to_another_tracker
|
def test_move_issues_to_another_tracker
|
||||||
@request.session[:user_id] = 1
|
@request.session[:user_id] = 1
|
||||||
post :move_issues, :id => 1, :issue_ids => [1, 2], :new_tracker_id => 3
|
post :move_issues, :id => 1, :issue_ids => [1, 2], :new_tracker_id => 2
|
||||||
assert_redirected_to 'projects/ecookbook/issues'
|
assert_redirected_to 'projects/ecookbook/issues'
|
||||||
assert_equal 3, Issue.find(1).tracker_id
|
assert_equal 2, Issue.find(1).tracker_id
|
||||||
assert_equal 3, Issue.find(2).tracker_id
|
assert_equal 2, Issue.find(2).tracker_id
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_list_files
|
def test_list_files
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
require File.dirname(__FILE__) + '/../test_helper'
|
require File.dirname(__FILE__) + '/../test_helper'
|
||||||
|
|
||||||
class ProjectTest < Test::Unit::TestCase
|
class ProjectTest < Test::Unit::TestCase
|
||||||
fixtures :projects, :issues, :issue_statuses, :journals, :journal_details, :users, :members, :roles
|
fixtures :projects, :issues, :issue_statuses, :journals, :journal_details, :users, :members, :roles, :projects_trackers, :trackers
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@ecookbook = Project.find(1)
|
@ecookbook = Project.find(1)
|
||||||
|
@ -112,6 +112,20 @@ class ProjectTest < Test::Unit::TestCase
|
||||||
sub.parent = Project.find(2)
|
sub.parent = Project.find(2)
|
||||||
assert !sub.save
|
assert !sub.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_rolled_up_trackers
|
||||||
|
parent = Project.find(1)
|
||||||
|
child = parent.children.find(3)
|
||||||
|
|
||||||
|
assert_equal [1, 2], parent.tracker_ids
|
||||||
|
assert_equal [2, 3], child.tracker_ids
|
||||||
|
|
||||||
|
assert_kind_of Tracker, parent.rolled_up_trackers.first
|
||||||
|
assert_equal Tracker.find(1), parent.rolled_up_trackers.first
|
||||||
|
|
||||||
|
assert_equal [1, 2, 3], parent.rolled_up_trackers.collect(&:id)
|
||||||
|
assert_equal [2, 3], child.rolled_up_trackers.collect(&:id)
|
||||||
|
end
|
||||||
|
|
||||||
def test_issues_status_changes
|
def test_issues_status_changes
|
||||||
journals = @ecookbook.issues_status_changes 3.days.ago.to_date, Date.today
|
journals = @ecookbook.issues_status_changes 3.days.ago.to_date, Date.today
|
||||||
|
|
Loading…
Reference in New Issue