diff --git a/app/models/document_category.rb b/app/models/document_category.rb index e04db7d1..0355b918 100644 --- a/app/models/document_category.rb +++ b/app/models/document_category.rb @@ -19,8 +19,6 @@ class DocumentCategory < Enumeration 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 diff --git a/app/models/enumeration.rb b/app/models/enumeration.rb index 4836229b..3b7a434a 100644 --- a/app/models/enumeration.rb +++ b/app/models/enumeration.rb @@ -29,36 +29,6 @@ class Enumeration < ActiveRecord::Base 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 } @@ -80,12 +50,6 @@ class Enumeration < ActiveRecord::Base 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}) diff --git a/app/models/issue_priority.rb b/app/models/issue_priority.rb index cea0f063..81c817b3 100644 --- a/app/models/issue_priority.rb +++ b/app/models/issue_priority.rb @@ -19,8 +19,6 @@ class IssuePriority < Enumeration 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 diff --git a/app/models/time_entry_activity.rb b/app/models/time_entry_activity.rb index 8e356715..4a612ac9 100644 --- a/app/models/time_entry_activity.rb +++ b/app/models/time_entry_activity.rb @@ -19,8 +19,6 @@ class TimeEntryActivity < Enumeration 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 diff --git a/db/migrate/20091225164732_remove_enumerations_opt.rb b/db/migrate/20091225164732_remove_enumerations_opt.rb new file mode 100644 index 00000000..72c39e05 --- /dev/null +++ b/db/migrate/20091225164732_remove_enumerations_opt.rb @@ -0,0 +1,12 @@ +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 diff --git a/lib/redmine/default_data/loader.rb b/lib/redmine/default_data/loader.rb index a8846672..7baeb976 100644 --- a/lib/redmine/default_data/loader.rb +++ b/lib/redmine/default_data/loader.rb @@ -160,17 +160,17 @@ module Redmine } # 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 diff --git a/lib/tasks/migrate_from_mantis.rake b/lib/tasks/migrate_from_mantis.rake index a7582a38..95722b12 100644 --- a/lib/tasks/migrate_from_mantis.rake +++ b/lib/tasks/migrate_from_mantis.rake @@ -40,7 +40,7 @@ task :migrate_from_mantis => :environment do 90 => closed_status # closed } - priorities = Enumeration.priorities + priorities = IssuePriority.all DEFAULT_PRIORITY = priorities[2] PRIORITY_MAPPING = {10 => priorities[1], # none 20 => priorities[1], # low diff --git a/lib/tasks/migrate_from_trac.rake b/lib/tasks/migrate_from_trac.rake index 1902af8d..e267a340 100644 --- a/lib/tasks/migrate_from_trac.rake +++ b/lib/tasks/migrate_from_trac.rake @@ -37,7 +37,7 @@ namespace :redmine do 'closed' => closed_status } - priorities = Enumeration.priorities + priorities = IssuePriority.all DEFAULT_PRIORITY = priorities[0] PRIORITY_MAPPING = {'lowest' => priorities[0], 'low' => priorities[0], diff --git a/test/fixtures/enumerations.yml b/test/fixtures/enumerations.yml index 5b9bc929..650a48c3 100644 --- a/test/fixtures/enumerations.yml +++ b/test/fixtures/enumerations.yml @@ -2,63 +2,53 @@ 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 @@ -66,27 +56,23 @@ enumerations_010: 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