@@ -0,0 +1,12 | |||||
|
1 | class RemoveEnumerationsOpt < ActiveRecord::Migration | |||
|
2 | def self.up | |||
|
3 | remove_column :enumerations, :opt | |||
|
4 | end | |||
|
5 | ||||
|
6 | def self.down | |||
|
7 | add_column :enumerations, :opt, :string, :limit => 4, :default => '', :null => false | |||
|
8 | Enumeration.update_all("opt = 'IPRI'", "type = 'IssuePriority'") | |||
|
9 | Enumeration.update_all("opt = 'DCAT'", "type = 'DocumentCategory'") | |||
|
10 | Enumeration.update_all("opt = 'ACTI'", "type = 'TimeEntryActivity'") | |||
|
11 | end | |||
|
12 | end |
@@ -19,8 +19,6 class DocumentCategory < Enumeration | |||||
19 | has_many :documents, :foreign_key => 'category_id' |
|
19 | has_many :documents, :foreign_key => 'category_id' | |
20 |
|
20 | |||
21 | OptionName = :enumeration_doc_categories |
|
21 | OptionName = :enumeration_doc_categories | |
22 | # Backwards compatiblity. Can be removed post-0.9 |
|
|||
23 | OptName = 'DCAT' |
|
|||
24 |
|
22 | |||
25 | def option_name |
|
23 | def option_name | |
26 | OptionName |
|
24 | OptionName |
@@ -29,36 +29,6 class Enumeration < ActiveRecord::Base | |||||
29 | validates_presence_of :name |
|
29 | validates_presence_of :name | |
30 | validates_uniqueness_of :name, :scope => [:type, :project_id] |
|
30 | validates_uniqueness_of :name, :scope => [:type, :project_id] | |
31 | validates_length_of :name, :maximum => 30 |
|
31 | validates_length_of :name, :maximum => 30 | |
32 |
|
||||
33 | # Backwards compatiblity named_scopes. |
|
|||
34 | # Can be removed post-0.9 |
|
|||
35 | named_scope :priorities, :conditions => { :type => "IssuePriority" }, :order => 'position' do |
|
|||
36 | ActiveSupport::Deprecation.warn("Enumeration#priorities is deprecated, use the IssuePriority class. (#{Redmine::Info.issue(3007)})") |
|
|||
37 | def default |
|
|||
38 | find(:first, :conditions => { :is_default => true }) |
|
|||
39 | end |
|
|||
40 | end |
|
|||
41 |
|
||||
42 | named_scope :document_categories, :conditions => { :type => "DocumentCategory" }, :order => 'position' do |
|
|||
43 | ActiveSupport::Deprecation.warn("Enumeration#document_categories is deprecated, use the DocumentCategories class. (#{Redmine::Info.issue(3007)})") |
|
|||
44 | def default |
|
|||
45 | find(:first, :conditions => { :is_default => true }) |
|
|||
46 | end |
|
|||
47 | end |
|
|||
48 |
|
||||
49 | named_scope :activities, :conditions => { :type => "TimeEntryActivity" }, :order => 'position' do |
|
|||
50 | ActiveSupport::Deprecation.warn("Enumeration#activities is deprecated, use the TimeEntryActivity class. (#{Redmine::Info.issue(3007)})") |
|
|||
51 | def default |
|
|||
52 | find(:first, :conditions => { :is_default => true }) |
|
|||
53 | end |
|
|||
54 | end |
|
|||
55 |
|
||||
56 | named_scope :values, lambda {|type| { :conditions => { :type => type }, :order => 'position' } } do |
|
|||
57 | def default |
|
|||
58 | find(:first, :conditions => { :is_default => true }) |
|
|||
59 | end |
|
|||
60 | end |
|
|||
61 | # End backwards compatiblity named_scopes |
|
|||
62 |
|
32 | |||
63 | named_scope :shared, :conditions => { :project_id => nil } |
|
33 | named_scope :shared, :conditions => { :project_id => nil } | |
64 | named_scope :active, :conditions => { :active => true } |
|
34 | named_scope :active, :conditions => { :active => true } | |
@@ -80,12 +50,6 class Enumeration < ActiveRecord::Base | |||||
80 | nil |
|
50 | nil | |
81 | end |
|
51 | end | |
82 |
|
52 | |||
83 | # Backwards compatiblity. Can be removed post-0.9 |
|
|||
84 | def opt |
|
|||
85 | ActiveSupport::Deprecation.warn("Enumeration#opt is deprecated, use the STI classes now. (#{Redmine::Info.issue(3007)})") |
|
|||
86 | return OptName |
|
|||
87 | end |
|
|||
88 |
|
||||
89 | def before_save |
|
53 | def before_save | |
90 | if is_default? && is_default_changed? |
|
54 | if is_default? && is_default_changed? | |
91 | Enumeration.update_all("is_default = #{connection.quoted_false}", {:type => type}) |
|
55 | Enumeration.update_all("is_default = #{connection.quoted_false}", {:type => type}) |
@@ -19,8 +19,6 class IssuePriority < Enumeration | |||||
19 | has_many :issues, :foreign_key => 'priority_id' |
|
19 | has_many :issues, :foreign_key => 'priority_id' | |
20 |
|
20 | |||
21 | OptionName = :enumeration_issue_priorities |
|
21 | OptionName = :enumeration_issue_priorities | |
22 | # Backwards compatiblity. Can be removed post-0.9 |
|
|||
23 | OptName = 'IPRI' |
|
|||
24 |
|
22 | |||
25 | def option_name |
|
23 | def option_name | |
26 | OptionName |
|
24 | OptionName |
@@ -19,8 +19,6 class TimeEntryActivity < Enumeration | |||||
19 | has_many :time_entries, :foreign_key => 'activity_id' |
|
19 | has_many :time_entries, :foreign_key => 'activity_id' | |
20 |
|
20 | |||
21 | OptionName = :enumeration_activities |
|
21 | OptionName = :enumeration_activities | |
22 | # Backwards compatiblity. Can be removed post-0.9 |
|
|||
23 | OptName = 'ACTI' |
|
|||
24 |
|
22 | |||
25 | def option_name |
|
23 | def option_name | |
26 | OptionName |
|
24 | OptionName |
@@ -160,17 +160,17 module Redmine | |||||
160 | } |
|
160 | } | |
161 |
|
161 | |||
162 | # Enumerations |
|
162 | # Enumerations | |
163 |
DocumentCategory.create!( |
|
163 | DocumentCategory.create!(:name => l(:default_doc_category_user), :position => 1) | |
164 |
DocumentCategory.create!( |
|
164 | DocumentCategory.create!(:name => l(:default_doc_category_tech), :position => 2) | |
165 |
|
165 | |||
166 |
IssuePriority.create!( |
|
166 | IssuePriority.create!(:name => l(:default_priority_low), :position => 1) | |
167 |
IssuePriority.create!( |
|
167 | IssuePriority.create!(:name => l(:default_priority_normal), :position => 2, :is_default => true) | |
168 |
IssuePriority.create!( |
|
168 | IssuePriority.create!(:name => l(:default_priority_high), :position => 3) | |
169 |
IssuePriority.create!( |
|
169 | IssuePriority.create!(:name => l(:default_priority_urgent), :position => 4) | |
170 |
IssuePriority.create!( |
|
170 | IssuePriority.create!(:name => l(:default_priority_immediate), :position => 5) | |
171 |
|
171 | |||
172 |
TimeEntryActivity.create!( |
|
172 | TimeEntryActivity.create!(:name => l(:default_activity_design), :position => 1) | |
173 |
TimeEntryActivity.create!( |
|
173 | TimeEntryActivity.create!(:name => l(:default_activity_development), :position => 2) | |
174 | end |
|
174 | end | |
175 | true |
|
175 | true | |
176 | end |
|
176 | end |
@@ -40,7 +40,7 task :migrate_from_mantis => :environment do | |||||
40 | 90 => closed_status # closed |
|
40 | 90 => closed_status # closed | |
41 | } |
|
41 | } | |
42 |
|
42 | |||
43 |
priorities = |
|
43 | priorities = IssuePriority.all | |
44 | DEFAULT_PRIORITY = priorities[2] |
|
44 | DEFAULT_PRIORITY = priorities[2] | |
45 | PRIORITY_MAPPING = {10 => priorities[1], # none |
|
45 | PRIORITY_MAPPING = {10 => priorities[1], # none | |
46 | 20 => priorities[1], # low |
|
46 | 20 => priorities[1], # low |
@@ -37,7 +37,7 namespace :redmine do | |||||
37 | 'closed' => closed_status |
|
37 | 'closed' => closed_status | |
38 | } |
|
38 | } | |
39 |
|
39 | |||
40 |
priorities = |
|
40 | priorities = IssuePriority.all | |
41 | DEFAULT_PRIORITY = priorities[0] |
|
41 | DEFAULT_PRIORITY = priorities[0] | |
42 | PRIORITY_MAPPING = {'lowest' => priorities[0], |
|
42 | PRIORITY_MAPPING = {'lowest' => priorities[0], | |
43 | 'low' => priorities[0], |
|
43 | 'low' => priorities[0], |
@@ -2,63 +2,53 | |||||
2 | enumerations_001: |
|
2 | enumerations_001: | |
3 | name: Uncategorized |
|
3 | name: Uncategorized | |
4 | id: 1 |
|
4 | id: 1 | |
5 | opt: DCAT |
|
|||
6 | type: DocumentCategory |
|
5 | type: DocumentCategory | |
7 | active: true |
|
6 | active: true | |
8 | enumerations_002: |
|
7 | enumerations_002: | |
9 | name: User documentation |
|
8 | name: User documentation | |
10 | id: 2 |
|
9 | id: 2 | |
11 | opt: DCAT |
|
|||
12 | type: DocumentCategory |
|
10 | type: DocumentCategory | |
13 | active: true |
|
11 | active: true | |
14 | enumerations_003: |
|
12 | enumerations_003: | |
15 | name: Technical documentation |
|
13 | name: Technical documentation | |
16 | id: 3 |
|
14 | id: 3 | |
17 | opt: DCAT |
|
|||
18 | type: DocumentCategory |
|
15 | type: DocumentCategory | |
19 | active: true |
|
16 | active: true | |
20 | enumerations_004: |
|
17 | enumerations_004: | |
21 | name: Low |
|
18 | name: Low | |
22 | id: 4 |
|
19 | id: 4 | |
23 | opt: IPRI |
|
|||
24 | type: IssuePriority |
|
20 | type: IssuePriority | |
25 | active: true |
|
21 | active: true | |
26 | enumerations_005: |
|
22 | enumerations_005: | |
27 | name: Normal |
|
23 | name: Normal | |
28 | id: 5 |
|
24 | id: 5 | |
29 | opt: IPRI |
|
|||
30 | type: IssuePriority |
|
25 | type: IssuePriority | |
31 | is_default: true |
|
26 | is_default: true | |
32 | active: true |
|
27 | active: true | |
33 | enumerations_006: |
|
28 | enumerations_006: | |
34 | name: High |
|
29 | name: High | |
35 | id: 6 |
|
30 | id: 6 | |
36 | opt: IPRI |
|
|||
37 | type: IssuePriority |
|
31 | type: IssuePriority | |
38 | active: true |
|
32 | active: true | |
39 | enumerations_007: |
|
33 | enumerations_007: | |
40 | name: Urgent |
|
34 | name: Urgent | |
41 | id: 7 |
|
35 | id: 7 | |
42 | opt: IPRI |
|
|||
43 | type: IssuePriority |
|
36 | type: IssuePriority | |
44 | active: true |
|
37 | active: true | |
45 | enumerations_008: |
|
38 | enumerations_008: | |
46 | name: Immediate |
|
39 | name: Immediate | |
47 | id: 8 |
|
40 | id: 8 | |
48 | opt: IPRI |
|
|||
49 | type: IssuePriority |
|
41 | type: IssuePriority | |
50 | active: true |
|
42 | active: true | |
51 | enumerations_009: |
|
43 | enumerations_009: | |
52 | name: Design |
|
44 | name: Design | |
53 | id: 9 |
|
45 | id: 9 | |
54 | opt: ACTI |
|
|||
55 | type: TimeEntryActivity |
|
46 | type: TimeEntryActivity | |
56 | position: 1 |
|
47 | position: 1 | |
57 | active: true |
|
48 | active: true | |
58 | enumerations_010: |
|
49 | enumerations_010: | |
59 | name: Development |
|
50 | name: Development | |
60 | id: 10 |
|
51 | id: 10 | |
61 | opt: ACTI |
|
|||
62 | type: TimeEntryActivity |
|
52 | type: TimeEntryActivity | |
63 | position: 2 |
|
53 | position: 2 | |
64 | is_default: true |
|
54 | is_default: true | |
@@ -66,27 +56,23 enumerations_010: | |||||
66 | enumerations_011: |
|
56 | enumerations_011: | |
67 | name: QA |
|
57 | name: QA | |
68 | id: 11 |
|
58 | id: 11 | |
69 | opt: ACTI |
|
|||
70 | type: TimeEntryActivity |
|
59 | type: TimeEntryActivity | |
71 | position: 3 |
|
60 | position: 3 | |
72 | active: true |
|
61 | active: true | |
73 | enumerations_012: |
|
62 | enumerations_012: | |
74 | name: Default Enumeration |
|
63 | name: Default Enumeration | |
75 | id: 12 |
|
64 | id: 12 | |
76 | opt: '' |
|
|||
77 | type: Enumeration |
|
65 | type: Enumeration | |
78 | is_default: true |
|
66 | is_default: true | |
79 | active: true |
|
67 | active: true | |
80 | enumerations_013: |
|
68 | enumerations_013: | |
81 | name: Another Enumeration |
|
69 | name: Another Enumeration | |
82 | id: 13 |
|
70 | id: 13 | |
83 | opt: '' |
|
|||
84 | type: Enumeration |
|
71 | type: Enumeration | |
85 | active: true |
|
72 | active: true | |
86 | enumerations_014: |
|
73 | enumerations_014: | |
87 | name: Inactive Activity |
|
74 | name: Inactive Activity | |
88 | id: 14 |
|
75 | id: 14 | |
89 | opt: ACTI |
|
|||
90 | type: TimeEntryActivity |
|
76 | type: TimeEntryActivity | |
91 | position: 4 |
|
77 | position: 4 | |
92 | active: false |
|
78 | active: false |
General Comments 0
You need to be logged in to leave comments.
Login now