Sha256: 4202740a480208b99864aca253d94fb747fe1415472180100018b63e591f1eb1

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

module Decidim
  module ActionDelegator
    # This mailer sends a notification email containing the result of importing a
    # CSV of results.
    class ImportMailer < Decidim::ApplicationMailer
      # 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.
      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
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
decidim-action_delegator-0.8.1 app/mailers/decidim/action_delegator/import_mailer.rb
decidim-action_delegator-0.7.2 app/mailers/decidim/action_delegator/import_mailer.rb
decidim-action_delegator-0.7.1 app/mailers/decidim/action_delegator/import_mailer.rb
decidim-action_delegator-0.7.0 app/mailers/decidim/action_delegator/import_mailer.rb