Move redmine plugin initialization to config.to_prepare.

- If plugin initialization happens in after_initialize, permissions are not evaluated correctly.
pull/6827/head
Christian Rijke 12 years ago
parent b6fc77453b
commit fcf4a9baa3
  1. 165
      lib/open_project/backlogs/engine.rb

@ -9,8 +9,8 @@ module OpenProject::Backlogs
{ :default => { "story_trackers" => nil, { :default => { "story_trackers" => nil,
"task_tracker" => nil, "task_tracker" => nil,
"card_spec" => nil "card_spec" => nil
}, },
:partial => 'shared/settings' } :partial => 'shared/settings' }
end end
config.autoload_paths += Dir["#{config.root}/lib/"] config.autoload_paths += Dir["#{config.root}/lib/"]
@ -80,91 +80,92 @@ module OpenProject::Backlogs
require_dependency 'open_project/backlogs/patches/version_controller_patch' require_dependency 'open_project/backlogs/patches/version_controller_patch'
require_dependency 'open_project/backlogs/patches/version_patch' require_dependency 'open_project/backlogs/patches/version_patch'
unless Redmine::Plugin.registered_plugins.include?(:openproject_backlogs)
Redmine::Plugin.register :openproject_backlogs do
name 'OpenProject Backlogs'
author 'relaxdiego, friflaj, Finn GmbH'
description 'A plugin for agile teams'
url 'https://github.com/finnlabs/openproject_backlogs'
author_url 'http://www.finn.de/'
version OpenProject::Backlogs::VERSION
#requires_redmine_plugin 'chiliproject_nissue', '1.0.0'
Redmine::AccessControl.permission(:edit_project).actions << "projects/project_issue_statuses"
Redmine::AccessControl.permission(:edit_project).actions << "projects/rebuild_positions"
settings Engine.settings
project_module :backlogs do
# SYNTAX: permission :name_of_permission, { :controller_name => [:action1, :action2] }
# Master backlog permissions
permission :view_master_backlog, {
:rb_master_backlogs => :index,
:rb_sprints => [:index, :show],
:rb_wikis => :show,
:rb_stories => [:index, :show],
:rb_queries => :show,
:rb_server_variables => :show,
:rb_burndown_charts => :show,
:issue_boxes => :show
}
permission :view_taskboards, {
:rb_taskboards => :show,
:rb_sprints => :show,
:rb_stories => [:index, :show],
:rb_tasks => [:index, :show],
:rb_impediments => [:index, :show],
:rb_wikis => :show,
:rb_server_variables => :show,
:rb_burndown_charts => :show
}
# Sprint permissions
# :show_sprints and :list_sprints are implicit in :view_master_backlog permission
permission :update_sprints, {
:rb_sprints => [:edit, :update],
:rb_wikis => [:edit, :update]
}
# Story permissions
# :show_stories and :list_stories are implicit in :view_master_backlog permission
permission :create_stories, { :rb_stories => :create }
permission :update_stories, { :rb_stories => :update,
:issue_boxes => [:edit, :update] }
# Task permissions
# :show_tasks and :list_tasks are implicit in :view_sprints
permission :create_tasks, { :rb_tasks => [:new, :create] }
permission :update_tasks, { :rb_tasks => [:edit, :update],
:issue_boxes => [:edit, :update] }
# Impediment permissions
# :show_impediments and :list_impediments are implicit in :view_sprints
permission :create_impediments, { :rb_impediments => [:new, :create] }
permission :update_impediments, { :rb_impediments => [:edit, :update],
:issue_boxes => [:edit, :update] }
end
menu :project_menu,
:backlogs,
{:controller => :rb_master_backlogs, :action => :index},
:caption => :project_module_backlogs,
:before => :calendar,
:param => :project_id,
:if => proc { not(User.current.respond_to?(:impaired?) and User.current.impaired?) }
end
end
end end
config.after_initialize do config.after_initialize do
# We are overwriting versions/_form.html.erb so our view must be found first # We are overwriting versions/_form.html.erb so our view must be found first
VersionsController.view_paths.unshift("#{config.root}/app/views") VersionsController.view_paths.unshift("#{config.root}/app/views")
Redmine::Plugin.register :openproject_backlogs do
name 'OpenProject Backlogs'
author 'relaxdiego, friflaj, Finn GmbH'
description 'A plugin for agile teams'
url 'https://github.com/finnlabs/openproject_backlogs'
author_url 'http://www.finn.de/'
version OpenProject::Backlogs::VERSION
#requires_redmine_plugin 'chiliproject_nissue', '1.0.0'
Redmine::AccessControl.permission(:edit_project).actions << "projects/project_issue_statuses"
Redmine::AccessControl.permission(:edit_project).actions << "projects/rebuild_positions"
settings Engine.settings
project_module :backlogs do
# SYNTAX: permission :name_of_permission, { :controller_name => [:action1, :action2] }
# Master backlog permissions
permission :view_master_backlog, {
:rb_master_backlogs => :index,
:rb_sprints => [:index, :show],
:rb_wikis => :show,
:rb_stories => [:index, :show],
:rb_queries => :show,
:rb_server_variables => :show,
:rb_burndown_charts => :show,
:issue_boxes => :show
}
permission :view_taskboards, {
:rb_taskboards => :show,
:rb_sprints => :show,
:rb_stories => [:index, :show],
:rb_tasks => [:index, :show],
:rb_impediments => [:index, :show],
:rb_wikis => :show,
:rb_server_variables => :show,
:rb_burndown_charts => :show
}
# Sprint permissions
# :show_sprints and :list_sprints are implicit in :view_master_backlog permission
permission :update_sprints, {
:rb_sprints => [:edit, :update],
:rb_wikis => [:edit, :update]
}
# Story permissions
# :show_stories and :list_stories are implicit in :view_master_backlog permission
permission :create_stories, { :rb_stories => :create }
permission :update_stories, { :rb_stories => :update,
:issue_boxes => [:edit, :update] }
# Task permissions
# :show_tasks and :list_tasks are implicit in :view_sprints
permission :create_tasks, { :rb_tasks => [:new, :create] }
permission :update_tasks, { :rb_tasks => [:edit, :update],
:issue_boxes => [:edit, :update] }
# Impediment permissions
# :show_impediments and :list_impediments are implicit in :view_sprints
permission :create_impediments, { :rb_impediments => [:new, :create] }
permission :update_impediments, { :rb_impediments => [:edit, :update],
:issue_boxes => [:edit, :update] }
end
menu :project_menu,
:backlogs,
{:controller => :rb_master_backlogs, :action => :index},
:caption => :project_module_backlogs,
:before => :calendar,
:param => :project_id,
:if => proc { not(User.current.respond_to?(:impaired?) and User.current.impaired?) }
end
end end
end end
end end

Loading…
Cancel
Save