@@ -1,88 +1,101 | |||
|
1 |
desc 'Load default configuration data |
|
|
1 | desc 'Load default configuration data' | |
|
2 | 2 | |
|
3 | 3 | task :load_default_data => :environment do |
|
4 | 4 | include GLoc |
|
5 | 5 | set_language_if_valid($RDM_DEFAULT_LANG) |
|
6 | ||
|
6 | puts | |
|
7 | ||
|
8 | while true | |
|
9 | print "Select language: " | |
|
10 | print GLoc.valid_languages.sort {|x,y| x.to_s <=> y.to_s }.join(", ") | |
|
11 | print " [#{GLoc.current_language}] " | |
|
12 | lang = STDIN.gets.chomp! | |
|
13 | break if lang.empty? | |
|
14 | break if set_language_if_valid(lang) | |
|
15 | puts "Unknown language!" | |
|
16 | end | |
|
17 | ||
|
18 | puts "====================================" | |
|
19 | ||
|
7 | 20 | begin |
|
8 | 21 | # check that no data already exists |
|
9 | 22 | if Role.find(:first) |
|
10 | 23 | raise "Some roles are already defined." |
|
11 | 24 | end |
|
12 | 25 | if Tracker.find(:first) |
|
13 | 26 | raise "Some trackers are already defined." |
|
14 | 27 | end |
|
15 | 28 | if IssueStatus.find(:first) |
|
16 | 29 | raise "Some statuses are already defined." |
|
17 | 30 | end |
|
18 | 31 | if Enumeration.find(:first) |
|
19 | 32 | raise "Some enumerations are already defined." |
|
20 | 33 | end |
|
21 | 34 | |
|
22 | puts "Loading default configuration for language: #{current_language}" | |
|
35 | puts "Loading default configuration data for language: #{current_language}" | |
|
23 | 36 | |
|
24 | 37 | # roles |
|
25 | 38 | manager = Role.create :name => l(:default_role_manager) |
|
26 | 39 | manager.permissions = Permission.find(:all, :conditions => ["is_public=?", false]) |
|
27 | 40 | |
|
28 | 41 | developper = Role.create :name => l(:default_role_developper) |
|
29 | 42 | perms = [150, 320, 321, 322, 420, 421, 422, 1050, 1060, 1070, 1075, 1130, 1220, 1221, 1222, 1223, 1224, 1320, 1322, 1061, 1057] |
|
30 | 43 | developper.permissions = Permission.find(:all, :conditions => ["sort IN (#{perms.join(',')})"]) |
|
31 | 44 | |
|
32 | 45 | reporter = Role.create :name => l(:default_role_reporter) |
|
33 | 46 | perms = [1050, 1060, 1070, 1057, 1130] |
|
34 | 47 | reporter.permissions = Permission.find(:all, :conditions => ["sort IN (#{perms.join(',')})"]) |
|
35 | 48 | |
|
36 | 49 | # trackers |
|
37 | 50 | Tracker.create(:name => l(:default_tracker_bug), :is_in_chlog => true) |
|
38 | 51 | Tracker.create(:name => l(:default_tracker_feature), :is_in_chlog => true) |
|
39 | 52 | Tracker.create(:name => l(:default_tracker_support), :is_in_chlog => false) |
|
40 | 53 | |
|
41 | 54 | # issue statuses |
|
42 | 55 | new = IssueStatus.create(:name => l(:default_issue_status_new), :is_closed => false, :is_default => true, :html_color => 'F98787') |
|
43 | 56 | assigned = IssueStatus.create(:name => l(:default_issue_status_assigned), :is_closed => false, :is_default => false, :html_color => 'C0C0FF') |
|
44 | 57 | resolved = IssueStatus.create(:name => l(:default_issue_status_resolved), :is_closed => false, :is_default => false, :html_color => '88E0B3') |
|
45 | 58 | feedback = IssueStatus.create(:name => l(:default_issue_status_feedback), :is_closed => false, :is_default => false, :html_color => 'F3A4F4') |
|
46 | 59 | closed = IssueStatus.create(:name => l(:default_issue_status_closed), :is_closed => true, :is_default => false, :html_color => 'DBDBDB') |
|
47 | 60 | rejected = IssueStatus.create(:name => l(:default_issue_status_rejected), :is_closed => true, :is_default => false, :html_color => 'F5C28B') |
|
48 | 61 | |
|
49 | 62 | # workflow |
|
50 | 63 | Tracker.find(:all).each { |t| |
|
51 | 64 | IssueStatus.find(:all).each { |os| |
|
52 | 65 | IssueStatus.find(:all).each { |ns| |
|
53 | 66 | Workflow.create(:tracker_id => t.id, :role_id => manager.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns |
|
54 | 67 | } |
|
55 | 68 | } |
|
56 | 69 | } |
|
57 | 70 | |
|
58 | 71 | Tracker.find(:all).each { |t| |
|
59 | 72 | [new, assigned, resolved, feedback].each { |os| |
|
60 | 73 | [assigned, resolved, feedback, closed].each { |ns| |
|
61 | 74 | Workflow.create(:tracker_id => t.id, :role_id => developper.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns |
|
62 | 75 | } |
|
63 | 76 | } |
|
64 | 77 | } |
|
65 | 78 | |
|
66 | 79 | Tracker.find(:all).each { |t| |
|
67 | 80 | [new, assigned, resolved, feedback].each { |os| |
|
68 | 81 | [closed].each { |ns| |
|
69 | 82 | Workflow.create(:tracker_id => t.id, :role_id => reporter.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns |
|
70 | 83 | } |
|
71 | 84 | } |
|
72 | 85 | Workflow.create(:tracker_id => t.id, :role_id => reporter.id, :old_status_id => resolved.id, :new_status_id => feedback.id) |
|
73 | 86 | } |
|
74 | 87 | |
|
75 | 88 | # enumerations |
|
76 | 89 | Enumeration.create(:opt => "DCAT", :name => l(:default_doc_category_user)) |
|
77 | 90 | Enumeration.create(:opt => "DCAT", :name => l(:default_doc_category_tech)) |
|
78 | 91 | Enumeration.create(:opt => "IPRI", :name => l(:default_priority_low)) |
|
79 | 92 | Enumeration.create(:opt => "IPRI", :name => l(:default_priority_normal)) |
|
80 | 93 | Enumeration.create(:opt => "IPRI", :name => l(:default_priority_high)) |
|
81 | 94 | Enumeration.create(:opt => "IPRI", :name => l(:default_priority_urgent)) |
|
82 | 95 | Enumeration.create(:opt => "IPRI", :name => l(:default_priority_immediate)) |
|
83 | 96 | |
|
84 | 97 | rescue => error |
|
85 | 98 | puts "Error: " + error |
|
86 | puts "Default configuration can't be loaded." | |
|
99 | puts "Default configuration data can't be loaded." | |
|
87 | 100 | end |
|
88 | 101 | end No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now