Project

General

Profile

« Previous | Next » 

Revision acfbc458

Added by Marek Hulán about 10 years ago

fixes #812 - new permissions model, user group role and nest support, role filters for better granularity

Contributions from:

View differences:

app/models/report.rb
class Report < ActiveRecord::Base
include Authorization
include Authorizable
include ReportCommon
belongs_to_host
......
# returns reports for hosts in the User's filter set
scope :my_reports, lambda {
unless User.current.admin? and Organization.current.nil? and Location.current.nil?
where(:reports => {:host_id => Host.my_hosts.select("hosts.id")})
host_ids = Host.authorized(:view_hosts, Host).select("hosts.id").all
where(:reports => {:host_id => host_ids})
end
}
......
private
def enforce_permissions operation
# No one can edit a report
return false if operation == "edit"
# Anyone can create a report
return true if operation == "create"
return true if operation == "destroy" and User.current.allowed_to?(:destroy_reports)
errors.add(:base, _("You do not have permission to %s this report") % operation)
false
end
# puppet report status table column name
def self.report_status
"status"

Also available in: Unified diff