summaryrefslogtreecommitdiffstats
path: root/lib/redmine/default_data/loader.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-01-05 11:33:49 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-01-05 11:33:49 +0000
commitc9fd7513edd0f594227fc681dcd654e41bd118e6 (patch)
tree90f582a920c1bc017d2342b53f23ea91230bd586 /lib/redmine/default_data/loader.rb
parent8d9b04865bac785d12b0aac43fe0c62488c39fec (diff)
downloadredmine-c9fd7513edd0f594227fc681dcd654e41bd118e6.tar.gz
redmine-c9fd7513edd0f594227fc681dcd654e41bd118e6.zip
Default configuration data can now be loaded from the administration screen.
A message is automatically displayed on this screen if roles, trackers,... have not been configured yet. The rake task is still available and the data loading code is wrapped in a transaction. git-svn-id: http://redmine.rubyforge.org/svn/trunk@1040 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/redmine/default_data/loader.rb')
-rw-r--r--lib/redmine/default_data/loader.rb215
1 files changed, 108 insertions, 107 deletions
diff --git a/lib/redmine/default_data/loader.rb b/lib/redmine/default_data/loader.rb
index 105219104..0abb5572a 100644
--- a/lib/redmine/default_data/loader.rb
+++ b/lib/redmine/default_data/loader.rb
@@ -38,19 +38,41 @@ module Redmine
raise DataAlreadyLoaded.new("Some configuration data is already loaded.") unless no_data?
set_language_if_valid(lang)
- # Roles
- manager = Role.create! :name => l(:default_role_manager),
- :position => 1
- manager.permissions = manager.setable_permissions.collect {|p| p.name}
- manager.save!
-
- developper = Role.create! :name => l(:default_role_developper),
- :position => 2,
- :permissions => [:manage_versions,
- :manage_categories,
- :add_issues,
- :edit_issues,
- :manage_issue_relations,
+ Role.transaction do
+ # Roles
+ manager = Role.create! :name => l(:default_role_manager),
+ :position => 1
+ manager.permissions = manager.setable_permissions.collect {|p| p.name}
+ manager.save!
+
+ developper = Role.create! :name => l(:default_role_developper),
+ :position => 2,
+ :permissions => [:manage_versions,
+ :manage_categories,
+ :add_issues,
+ :edit_issues,
+ :manage_issue_relations,
+ :add_issue_notes,
+ :change_issue_status,
+ :save_queries,
+ :view_gantt,
+ :view_calendar,
+ :log_time,
+ :view_time_entries,
+ :comment_news,
+ :view_documents,
+ :view_wiki_pages,
+ :edit_wiki_pages,
+ :delete_wiki_pages,
+ :add_messages,
+ :view_files,
+ :manage_files,
+ :browse_repository,
+ :view_changesets]
+
+ reporter = Role.create! :name => l(:default_role_reporter),
+ :position => 3,
+ :permissions => [:add_issues,
:add_issue_notes,
:change_issue_status,
:save_queries,
@@ -61,108 +83,87 @@ module Redmine
:comment_news,
:view_documents,
:view_wiki_pages,
- :edit_wiki_pages,
- :delete_wiki_pages,
:add_messages,
:view_files,
- :manage_files,
:browse_repository,
:view_changesets]
+
+ Role.non_member.update_attribute :permissions, [:add_issues,
+ :add_issue_notes,
+ :change_issue_status,
+ :save_queries,
+ :view_gantt,
+ :view_calendar,
+ :view_time_entries,
+ :comment_news,
+ :view_documents,
+ :view_wiki_pages,
+ :add_messages,
+ :view_files,
+ :browse_repository,
+ :view_changesets]
- reporter = Role.create! :name => l(:default_role_reporter),
- :position => 3,
- :permissions => [:add_issues,
- :add_issue_notes,
- :change_issue_status,
- :save_queries,
- :view_gantt,
- :view_calendar,
- :log_time,
- :view_time_entries,
- :comment_news,
- :view_documents,
- :view_wiki_pages,
- :add_messages,
- :view_files,
- :browse_repository,
- :view_changesets]
-
- Role.non_member.update_attribute :permissions, [:add_issues,
- :add_issue_notes,
- :change_issue_status,
- :save_queries,
- :view_gantt,
- :view_calendar,
- :view_time_entries,
- :comment_news,
- :view_documents,
- :view_wiki_pages,
- :add_messages,
- :view_files,
- :browse_repository,
- :view_changesets]
-
- Role.anonymous.update_attribute :permissions, [:view_gantt,
- :view_calendar,
- :view_time_entries,
- :view_documents,
- :view_wiki_pages,
- :view_files,
- :browse_repository,
- :view_changesets]
-
- # Trackers
- Tracker.create!(:name => l(:default_tracker_bug), :is_in_chlog => true, :is_in_roadmap => false, :position => 1)
- Tracker.create!(:name => l(:default_tracker_feature), :is_in_chlog => true, :is_in_roadmap => true, :position => 2)
- Tracker.create!(:name => l(:default_tracker_support), :is_in_chlog => false, :is_in_roadmap => false, :position => 3)
-
- # Issue statuses
- new = IssueStatus.create!(:name => l(:default_issue_status_new), :is_closed => false, :is_default => true, :position => 1)
- assigned = IssueStatus.create!(:name => l(:default_issue_status_assigned), :is_closed => false, :is_default => false, :position => 2)
- resolved = IssueStatus.create!(:name => l(:default_issue_status_resolved), :is_closed => false, :is_default => false, :position => 3)
- feedback = IssueStatus.create!(:name => l(:default_issue_status_feedback), :is_closed => false, :is_default => false, :position => 4)
- closed = IssueStatus.create!(:name => l(:default_issue_status_closed), :is_closed => true, :is_default => false, :position => 5)
- rejected = IssueStatus.create!(:name => l(:default_issue_status_rejected), :is_closed => true, :is_default => false, :position => 6)
-
- # Workflow
- Tracker.find(:all).each { |t|
- IssueStatus.find(:all).each { |os|
- IssueStatus.find(:all).each { |ns|
- Workflow.create!(:tracker_id => t.id, :role_id => manager.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns
- }
- }
- }
+ Role.anonymous.update_attribute :permissions, [:view_gantt,
+ :view_calendar,
+ :view_time_entries,
+ :view_documents,
+ :view_wiki_pages,
+ :view_files,
+ :browse_repository,
+ :view_changesets]
+
+ # Trackers
+ Tracker.create!(:name => l(:default_tracker_bug), :is_in_chlog => true, :is_in_roadmap => false, :position => 1)
+ Tracker.create!(:name => l(:default_tracker_feature), :is_in_chlog => true, :is_in_roadmap => true, :position => 2)
+ Tracker.create!(:name => l(:default_tracker_support), :is_in_chlog => false, :is_in_roadmap => false, :position => 3)
+
+ # Issue statuses
+ new = IssueStatus.create!(:name => l(:default_issue_status_new), :is_closed => false, :is_default => true, :position => 1)
+ assigned = IssueStatus.create!(:name => l(:default_issue_status_assigned), :is_closed => false, :is_default => false, :position => 2)
+ resolved = IssueStatus.create!(:name => l(:default_issue_status_resolved), :is_closed => false, :is_default => false, :position => 3)
+ feedback = IssueStatus.create!(:name => l(:default_issue_status_feedback), :is_closed => false, :is_default => false, :position => 4)
+ closed = IssueStatus.create!(:name => l(:default_issue_status_closed), :is_closed => true, :is_default => false, :position => 5)
+ rejected = IssueStatus.create!(:name => l(:default_issue_status_rejected), :is_closed => true, :is_default => false, :position => 6)
+
+ # Workflow
+ Tracker.find(:all).each { |t|
+ IssueStatus.find(:all).each { |os|
+ IssueStatus.find(:all).each { |ns|
+ Workflow.create!(:tracker_id => t.id, :role_id => manager.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns
+ }
+ }
+ }
+
+ Tracker.find(:all).each { |t|
+ [new, assigned, resolved, feedback].each { |os|
+ [assigned, resolved, feedback, closed].each { |ns|
+ Workflow.create!(:tracker_id => t.id, :role_id => developper.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns
+ }
+ }
+ }
+
+ Tracker.find(:all).each { |t|
+ [new, assigned, resolved, feedback].each { |os|
+ [closed].each { |ns|
+ Workflow.create!(:tracker_id => t.id, :role_id => reporter.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns
+ }
+ }
+ Workflow.create!(:tracker_id => t.id, :role_id => reporter.id, :old_status_id => resolved.id, :new_status_id => feedback.id)
+ }
- Tracker.find(:all).each { |t|
- [new, assigned, resolved, feedback].each { |os|
- [assigned, resolved, feedback, closed].each { |ns|
- Workflow.create!(:tracker_id => t.id, :role_id => developper.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns
- }
- }
- }
+ # Enumerations
+ Enumeration.create!(:opt => "DCAT", :name => l(:default_doc_category_user), :position => 1)
+ Enumeration.create!(:opt => "DCAT", :name => l(:default_doc_category_tech), :position => 2)
- Tracker.find(:all).each { |t|
- [new, assigned, resolved, feedback].each { |os|
- [closed].each { |ns|
- Workflow.create!(:tracker_id => t.id, :role_id => reporter.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns
- }
- }
- Workflow.create!(:tracker_id => t.id, :role_id => reporter.id, :old_status_id => resolved.id, :new_status_id => feedback.id)
- }
-
- # Enumerations
- Enumeration.create!(:opt => "DCAT", :name => l(:default_doc_category_user), :position => 1)
- Enumeration.create!(:opt => "DCAT", :name => l(:default_doc_category_tech), :position => 2)
-
- Enumeration.create!(:opt => "IPRI", :name => l(:default_priority_low), :position => 1)
- Enumeration.create!(:opt => "IPRI", :name => l(:default_priority_normal), :position => 2, :is_default => true)
- Enumeration.create!(:opt => "IPRI", :name => l(:default_priority_high), :position => 3)
- Enumeration.create!(:opt => "IPRI", :name => l(:default_priority_urgent), :position => 4)
- Enumeration.create!(:opt => "IPRI", :name => l(:default_priority_immediate), :position => 5)
-
- Enumeration.create!(:opt => "ACTI", :name => l(:default_activity_design), :position => 1)
- Enumeration.create!(:opt => "ACTI", :name => l(:default_activity_development), :position => 2)
+ Enumeration.create!(:opt => "IPRI", :name => l(:default_priority_low), :position => 1)
+ Enumeration.create!(:opt => "IPRI", :name => l(:default_priority_normal), :position => 2, :is_default => true)
+ Enumeration.create!(:opt => "IPRI", :name => l(:default_priority_high), :position => 3)
+ Enumeration.create!(:opt => "IPRI", :name => l(:default_priority_urgent), :position => 4)
+ Enumeration.create!(:opt => "IPRI", :name => l(:default_priority_immediate), :position => 5)
+ Enumeration.create!(:opt => "ACTI", :name => l(:default_activity_design), :position => 1)
+ Enumeration.create!(:opt => "ACTI", :name => l(:default_activity_development), :position => 2)
+ end
true
end
end