|
|
|
@ -2,6 +2,8 @@ module Report::Controller |
|
|
|
|
def self.included(base) |
|
|
|
|
base.class_eval do |
|
|
|
|
attr_accessor :report_engine |
|
|
|
|
helper_method :current_user |
|
|
|
|
helper_method :allowed_to? |
|
|
|
|
|
|
|
|
|
include ReportingHelper |
|
|
|
|
helper ReportingHelper |
|
|
|
@ -302,6 +304,21 @@ module Report::Controller |
|
|
|
|
'user_id' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
## |
|
|
|
|
# Fallback: @current_user needs to be set for the engine |
|
|
|
|
def current_user |
|
|
|
|
if @current_user.nil? |
|
|
|
|
raise NotImplementedError, "The #{self.class} should have set @current_user before this request" |
|
|
|
|
end |
|
|
|
|
@current_user |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
## |
|
|
|
|
# Abstract: Implementation required in application |
|
|
|
|
def allowed_to?(action, subject, user = current_user) |
|
|
|
|
raise NotImplementedError, "The #{self.class} should have implemented #allowed_to?(action, subject, user)" |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
## |
|
|
|
|
# Find a report if :id was passed as parameter. |
|
|
|
|
# Raises RecordNotFound if an invalid :id was passed. |
|
|
|
|