Class: Decidim::ActionDelegator::ImportMailer

Inherits:
Decidim::ApplicationMailer
  • Object
show all
Defined in:
app/mailers/decidim/action_delegator/import_mailer.rb

Overview

This mailer sends a notification email containing the result of importing a CSV of results.

Instance Method Summary collapse

Instance Method Details

#import(user, import_summary, csv_file_path) ⇒ Object

Public: Sends a notification email with the result of a CSV import of results.

user - The user to be notified. errors - The list of errors generated by the import

Returns nothing.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/mailers/decidim/action_delegator/import_mailer.rb', line 15

def import(user, import_summary, csv_file_path)
  @user = user
  @organization = user.organization
  @import_summary = import_summary
  @csv_file_path = csv_file_path

  @csv_file_path = "" if @import_summary[:total_rows] == @import_summary[:imported_rows]

  attachments["details.csv"] = File.read(@csv_file_path) if @csv_file_path.present? && File.exist?(@csv_file_path)

  with_user(user) do
    mail(to: "#{user.name} <#{user.email}>", subject: I18n.t("decidim.action_delegator.import_mailer.import.subject"))
  end
end