Mercurial > hg > soundsoftware-site
comparison lib/redmine/default_data/loader.rb @ 1298:4f746d8966dd redmine_2.3_integration
Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:28:30 +0100 |
parents | 622f24f53b42 |
children | e248c7af89ec |
comparison
equal
deleted
inserted
replaced
1297:0a574315af3e | 1298:4f746d8966dd |
---|---|
1 # Redmine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2012 Jean-Philippe Lang | 2 # Copyright (C) 2006-2013 Jean-Philippe Lang |
3 # | 3 # |
4 # This program is free software; you can redistribute it and/or | 4 # This program is free software; you can redistribute it and/or |
5 # modify it under the terms of the GNU General Public License | 5 # modify it under the terms of the GNU General Public License |
6 # as published by the Free Software Foundation; either version 2 | 6 # as published by the Free Software Foundation; either version 2 |
7 # of the License, or (at your option) any later version. | 7 # of the License, or (at your option) any later version. |
24 | 24 |
25 class << self | 25 class << self |
26 # Returns true if no data is already loaded in the database | 26 # Returns true if no data is already loaded in the database |
27 # otherwise false | 27 # otherwise false |
28 def no_data? | 28 def no_data? |
29 !Role.find(:first, :conditions => {:builtin => 0}) && | 29 !Role.where(:builtin => 0).exists? && |
30 !Tracker.find(:first) && | 30 !Tracker.exists? && |
31 !IssueStatus.find(:first) && | 31 !IssueStatus.exists? && |
32 !Enumeration.find(:first) | 32 !Enumeration.exists? |
33 end | 33 end |
34 | 34 |
35 # Loads the default data | 35 # Loads the default data |
36 # Raises a RecordNotSaved exception if something goes wrong | 36 # Raises a RecordNotSaved exception if something goes wrong |
37 def load(lang=nil) | 37 def load(lang=nil) |
137 feedback = IssueStatus.create!(:name => l(:default_issue_status_feedback), :is_closed => false, :is_default => false, :position => 4) | 137 feedback = IssueStatus.create!(:name => l(:default_issue_status_feedback), :is_closed => false, :is_default => false, :position => 4) |
138 closed = IssueStatus.create!(:name => l(:default_issue_status_closed), :is_closed => true, :is_default => false, :position => 5) | 138 closed = IssueStatus.create!(:name => l(:default_issue_status_closed), :is_closed => true, :is_default => false, :position => 5) |
139 rejected = IssueStatus.create!(:name => l(:default_issue_status_rejected), :is_closed => true, :is_default => false, :position => 6) | 139 rejected = IssueStatus.create!(:name => l(:default_issue_status_rejected), :is_closed => true, :is_default => false, :position => 6) |
140 | 140 |
141 # Workflow | 141 # Workflow |
142 Tracker.find(:all).each { |t| | 142 Tracker.all.each { |t| |
143 IssueStatus.find(:all).each { |os| | 143 IssueStatus.all.each { |os| |
144 IssueStatus.find(:all).each { |ns| | 144 IssueStatus.all.each { |ns| |
145 WorkflowTransition.create!(:tracker_id => t.id, :role_id => manager.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns | 145 WorkflowTransition.create!(:tracker_id => t.id, :role_id => manager.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns |
146 } | 146 } |
147 } | 147 } |
148 } | 148 } |
149 | 149 |
150 Tracker.find(:all).each { |t| | 150 Tracker.all.each { |t| |
151 [new, in_progress, resolved, feedback].each { |os| | 151 [new, in_progress, resolved, feedback].each { |os| |
152 [in_progress, resolved, feedback, closed].each { |ns| | 152 [in_progress, resolved, feedback, closed].each { |ns| |
153 WorkflowTransition.create!(:tracker_id => t.id, :role_id => developer.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns | 153 WorkflowTransition.create!(:tracker_id => t.id, :role_id => developer.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns |
154 } | 154 } |
155 } | 155 } |
156 } | 156 } |
157 | 157 |
158 Tracker.find(:all).each { |t| | 158 Tracker.all.each { |t| |
159 [new, in_progress, resolved, feedback].each { |os| | 159 [new, in_progress, resolved, feedback].each { |os| |
160 [closed].each { |ns| | 160 [closed].each { |ns| |
161 WorkflowTransition.create!(:tracker_id => t.id, :role_id => reporter.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns | 161 WorkflowTransition.create!(:tracker_id => t.id, :role_id => reporter.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns |
162 } | 162 } |
163 } | 163 } |