diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-11-02 19:45:14 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-11-02 19:45:14 +0000 |
commit | dfc594c33702a123674dcae1d6b4bfe3a2f32fd3 (patch) | |
tree | 42f8653451b35f54db68bf914e1d963bfaf13418 /app/models/tracker.rb | |
parent | 32b79b6fd4e3a523ee393d7a3e2bb60dbeed77c3 (diff) | |
download | redmine-dfc594c33702a123674dcae1d6b4bfe3a2f32fd3.tar.gz redmine-dfc594c33702a123674dcae1d6b4bfe3a2f32fd3.zip |
Default status per tracker (#5991).
git-svn-id: http://svn.redmine.org/redmine/trunk@13535 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/tracker.rb')
-rw-r--r-- | app/models/tracker.rb | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/app/models/tracker.rb b/app/models/tracker.rb index 1c867c5f1..4b86a7ecb 100644 --- a/app/models/tracker.rb +++ b/app/models/tracker.rb @@ -24,6 +24,7 @@ class Tracker < ActiveRecord::Base CORE_FIELDS_ALL = (CORE_FIELDS_UNDISABLABLE + CORE_FIELDS).freeze before_destroy :check_integrity + belongs_to :default_status, :class_name => 'IssueStatus' has_many :issues has_many :workflow_rules, :dependent => :delete_all do def copy(source_tracker) @@ -37,6 +38,7 @@ class Tracker < ActiveRecord::Base attr_protected :fields_bits + validates_presence_of :default_status validates_presence_of :name validates_uniqueness_of :name validates_length_of :name, :maximum => 30 @@ -53,14 +55,15 @@ class Tracker < ActiveRecord::Base # Returns an array of IssueStatus that are used # in the tracker's workflows def issue_statuses - if @issue_statuses - return @issue_statuses - elsif new_record? - return [] - end + @issue_statuses ||= IssueStatus.where(:id => issue_status_ids).to_a.sort + end - status_ids = WorkflowTransition.where(:tracker_id => id).uniq.pluck(:old_status_id, :new_status_id).flatten.uniq - @issue_statuses = IssueStatus.where(:id => status_ids).to_a.sort + def issue_status_ids + if new_record? + [] + else + @issue_status_ids ||= WorkflowTransition.where(:tracker_id => id).uniq.pluck(:old_status_id, :new_status_id).flatten.uniq + end end def disabled_core_fields |