diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-08-29 16:52:35 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-08-29 16:52:35 +0000 |
commit | 603e11d7a5aa62f923e7b013cac6c66462131232 (patch) | |
tree | fbbb204d2b92b5a87b787d56fe3f9c62cc3f259b /lib/tasks | |
parent | 8da5bad29516be6cbe1bc52e78837ac1ec292026 (diff) | |
download | redmine-603e11d7a5aa62f923e7b013cac6c66462131232.tar.gz redmine-603e11d7a5aa62f923e7b013cac6c66462131232.zip |
Merged 0.6 branch into trunk.
Permissions management was rewritten. Some permissions can now be specifically defined for non member and anonymous users.
This migration:
* is irreversible (please, don't forget to *backup* your database before upgrading)
* resets role's permissions (go to "Admin -> Roles & Permissions" to set them after upgrading)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@674 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/tasks')
-rw-r--r-- | lib/tasks/load_default_data.rake | 81 |
1 files changed, 71 insertions, 10 deletions
diff --git a/lib/tasks/load_default_data.rake b/lib/tasks/load_default_data.rake index 488cd2a64..e59c3c5fe 100644 --- a/lib/tasks/load_default_data.rake +++ b/lib/tasks/load_default_data.rake @@ -19,7 +19,7 @@ task :load_default_data => :environment do begin
# check that no data already exists
- if Role.find(:first)
+ if Role.find(:first, :conditions => {:builtin => 0})
raise "Some roles are already defined."
end
if Tracker.find(:first)
@@ -35,17 +35,78 @@ begin puts "Loading default configuration data for language: #{current_language}"
# roles
- manager = Role.create :name => l(:default_role_manager), :position => 1
- manager.permissions = Permission.find(:all, :conditions => ["is_public=?", false])
+ 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
- perms = [150, 320, 321, 322, 420, 421, 422, 1050, 1060, 1070, 1075, 1130, 1220, 1221, 1222, 1223, 1224, 1320, 1322, 1061, 1057, 1520]
- developper.permissions = Permission.find(:all, :conditions => ["sort IN (#{perms.join(',')})"])
-
- reporter = Role.create :name => l(:default_role_reporter), :position => 3
- perms = [1050, 1060, 1070, 1057, 1130]
- reporter.permissions = Permission.find(:all, :conditions => ["sort IN (#{perms.join(',')})"])
+ 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,
+ :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)
|