Revision 9b33f22f
Added by Lukas Zapletal almost 9 years ago
app/services/foreman/plugin.rb | ||
---|---|---|
end
|
||
|
||
def_field :name, :description, :url, :author, :author_url, :version, :path
|
||
attr_reader :id, :logging
|
||
attr_reader :id, :logging, :default_roles
|
||
|
||
def initialize(id)
|
||
@id = id.to_sym
|
||
@logging = Plugin::Logging.new(@id)
|
||
@default_roles = {}
|
||
end
|
||
|
||
def after_initialize
|
||
... | ... | |
|
||
# Add a new role if it doesn't exist
|
||
def role(name, permissions)
|
||
return false if pending_migrations
|
||
@default_roles[name] = permissions
|
||
return false if pending_migrations || Rails.env.test?
|
||
|
||
Role.transaction do
|
||
role = Role.find_or_create_by_name(name)
|
Also available in: Unified diff
Fixes #11206 - plugin API now expose default role permissions
(cherry picked from commit 758d57a3c067dbd07f5bfbd66617b6865dab9d66)