foreman/app/mailers/audit_mailer.rb @ 9d43fc71
bc9558f7 | Shlomi Zadok | class AuditMailer < ApplicationMailer
|
|
helper :audits, :layout
|
|||
def summary(options = {})
|
|||
9d43fc71 | Michael Moll | raise ::Foreman::Exception.new(N_("Must specify a user with email enabled")) unless (user = User.unscoped.find(options[:user])) && user.mail_enabled?
|
|
bc9558f7 | Shlomi Zadok | time = options[:time] ? %(time >= "#{options[:time]}") : 'time > yesterday'
|
|
f4459c11 | David Davis | @query = options[:query].present? ? "#{options[:query]} and #{time}" : time.to_s
|
|
bc9558f7 | Shlomi Zadok | @count = Audit.authorized_as(user, :view_audit_logs, Audit).search_for(@query).count
|
|
da9865b8 | Michael Moll | @limit = (Setting[:entries_per_page] > @count) ? @count : Setting[:entries_per_page]
|
|
bc9558f7 | Shlomi Zadok | @audits = Audit.authorized_as(user, :view_audit_logs, Audit).search_for(@query).limit(@limit)
|
|
c8042418 | Dominic Cleal | set_locale_for(user) do
|
|
a1506cab | amirfefer | mail(:to => user.mail, :subject => _("Audit summary")) do |format|
|
|
format.html { render :layout => 'application_mailer' }
|
|||
format.text
|
|||
end
|
|||
c8042418 | Dominic Cleal | end
|
|
bc9558f7 | Shlomi Zadok | end
|
|
end
|