has_many :documents, :foreign_key => 'category_id'
OptionName = :enumeration_doc_categories
- # Backwards compatiblity. Can be removed post-0.9
- OptName = 'DCAT'
def option_name
OptionName
validates_presence_of :name
validates_uniqueness_of :name, :scope => [:type, :project_id]
validates_length_of :name, :maximum => 30
-
- # Backwards compatiblity named_scopes.
- # Can be removed post-0.9
- named_scope :priorities, :conditions => { :type => "IssuePriority" }, :order => 'position' do
- ActiveSupport::Deprecation.warn("Enumeration#priorities is deprecated, use the IssuePriority class. (#{Redmine::Info.issue(3007)})")
- def default
- find(:first, :conditions => { :is_default => true })
- end
- end
-
- named_scope :document_categories, :conditions => { :type => "DocumentCategory" }, :order => 'position' do
- ActiveSupport::Deprecation.warn("Enumeration#document_categories is deprecated, use the DocumentCategories class. (#{Redmine::Info.issue(3007)})")
- def default
- find(:first, :conditions => { :is_default => true })
- end
- end
-
- named_scope :activities, :conditions => { :type => "TimeEntryActivity" }, :order => 'position' do
- ActiveSupport::Deprecation.warn("Enumeration#activities is deprecated, use the TimeEntryActivity class. (#{Redmine::Info.issue(3007)})")
- def default
- find(:first, :conditions => { :is_default => true })
- end
- end
-
- named_scope :values, lambda {|type| { :conditions => { :type => type }, :order => 'position' } } do
- def default
- find(:first, :conditions => { :is_default => true })
- end
- end
- # End backwards compatiblity named_scopes
named_scope :shared, :conditions => { :project_id => nil }
named_scope :active, :conditions => { :active => true }
nil
end
- # Backwards compatiblity. Can be removed post-0.9
- def opt
- ActiveSupport::Deprecation.warn("Enumeration#opt is deprecated, use the STI classes now. (#{Redmine::Info.issue(3007)})")
- return OptName
- end
-
def before_save
if is_default? && is_default_changed?
Enumeration.update_all("is_default = #{connection.quoted_false}", {:type => type})
has_many :issues, :foreign_key => 'priority_id'
OptionName = :enumeration_issue_priorities
- # Backwards compatiblity. Can be removed post-0.9
- OptName = 'IPRI'
def option_name
OptionName
has_many :time_entries, :foreign_key => 'activity_id'
OptionName = :enumeration_activities
- # Backwards compatiblity. Can be removed post-0.9
- OptName = 'ACTI'
def option_name
OptionName
--- /dev/null
+class RemoveEnumerationsOpt < ActiveRecord::Migration
+ def self.up
+ remove_column :enumerations, :opt
+ end
+
+ def self.down
+ add_column :enumerations, :opt, :string, :limit => 4, :default => '', :null => false
+ Enumeration.update_all("opt = 'IPRI'", "type = 'IssuePriority'")
+ Enumeration.update_all("opt = 'DCAT'", "type = 'DocumentCategory'")
+ Enumeration.update_all("opt = 'ACTI'", "type = 'TimeEntryActivity'")
+ end
+end
}
# Enumerations
- DocumentCategory.create!(:opt => "DCAT", :name => l(:default_doc_category_user), :position => 1)
- DocumentCategory.create!(:opt => "DCAT", :name => l(:default_doc_category_tech), :position => 2)
+ DocumentCategory.create!(:name => l(:default_doc_category_user), :position => 1)
+ DocumentCategory.create!(:name => l(:default_doc_category_tech), :position => 2)
- IssuePriority.create!(:opt => "IPRI", :name => l(:default_priority_low), :position => 1)
- IssuePriority.create!(:opt => "IPRI", :name => l(:default_priority_normal), :position => 2, :is_default => true)
- IssuePriority.create!(:opt => "IPRI", :name => l(:default_priority_high), :position => 3)
- IssuePriority.create!(:opt => "IPRI", :name => l(:default_priority_urgent), :position => 4)
- IssuePriority.create!(:opt => "IPRI", :name => l(:default_priority_immediate), :position => 5)
+ IssuePriority.create!(:name => l(:default_priority_low), :position => 1)
+ IssuePriority.create!(:name => l(:default_priority_normal), :position => 2, :is_default => true)
+ IssuePriority.create!(:name => l(:default_priority_high), :position => 3)
+ IssuePriority.create!(:name => l(:default_priority_urgent), :position => 4)
+ IssuePriority.create!(:name => l(:default_priority_immediate), :position => 5)
- TimeEntryActivity.create!(:opt => "ACTI", :name => l(:default_activity_design), :position => 1)
- TimeEntryActivity.create!(:opt => "ACTI", :name => l(:default_activity_development), :position => 2)
+ TimeEntryActivity.create!(:name => l(:default_activity_design), :position => 1)
+ TimeEntryActivity.create!(:name => l(:default_activity_development), :position => 2)
end
true
end
90 => closed_status # closed\r
}\r
\r
- priorities = Enumeration.priorities\r
+ priorities = IssuePriority.all\r
DEFAULT_PRIORITY = priorities[2]\r
PRIORITY_MAPPING = {10 => priorities[1], # none\r
20 => priorities[1], # low\r
'closed' => closed_status
}
- priorities = Enumeration.priorities
+ priorities = IssuePriority.all
DEFAULT_PRIORITY = priorities[0]
PRIORITY_MAPPING = {'lowest' => priorities[0],
'low' => priorities[0],
enumerations_001:
name: Uncategorized
id: 1
- opt: DCAT
type: DocumentCategory
active: true
enumerations_002:
name: User documentation
id: 2
- opt: DCAT
type: DocumentCategory
active: true
enumerations_003:
name: Technical documentation
id: 3
- opt: DCAT
type: DocumentCategory
active: true
enumerations_004:
name: Low
id: 4
- opt: IPRI
type: IssuePriority
active: true
enumerations_005:
name: Normal
id: 5
- opt: IPRI
type: IssuePriority
is_default: true
active: true
enumerations_006:
name: High
id: 6
- opt: IPRI
type: IssuePriority
active: true
enumerations_007:
name: Urgent
id: 7
- opt: IPRI
type: IssuePriority
active: true
enumerations_008:
name: Immediate
id: 8
- opt: IPRI
type: IssuePriority
active: true
enumerations_009:
name: Design
id: 9
- opt: ACTI
type: TimeEntryActivity
position: 1
active: true
enumerations_010:
name: Development
id: 10
- opt: ACTI
type: TimeEntryActivity
position: 2
is_default: true
enumerations_011:
name: QA
id: 11
- opt: ACTI
type: TimeEntryActivity
position: 3
active: true
enumerations_012:
name: Default Enumeration
id: 12
- opt: ''
type: Enumeration
is_default: true
active: true
enumerations_013:
name: Another Enumeration
id: 13
- opt: ''
type: Enumeration
active: true
enumerations_014:
name: Inactive Activity
id: 14
- opt: ACTI
type: TimeEntryActivity
position: 4
active: false