Sha256: 594ed1cf6f1db578f66290ca03b5b8cc1d5b2f377a064281b98a9597d00828b0

Contents?: true

Size: 1.58 KB

Versions: 13

Compression:

Stored size: 1.58 KB

Contents

# frozen_string_literal: true

module Decidim
  module Conferences
    module Admin
      # A custom mailer for sending the diploma of the conference to
      # a registered user who attends to the conference.
      class SendConferenceDiplomaMailer < Decidim::ApplicationMailer
        include Decidim::TranslationsHelper
        include Decidim::SanitizeHelper

        helper Decidim::ResourceHelper
        helper Decidim::TranslationsHelper

        # Send an email to an user with the diploma of conference attendance attached.
        #
        # user - The user being invited
        # conference - The conference being joined.
        def diploma(conference, user)
          with_user(user) do
            @user = user
            @conference = conference
            @organization = @conference.organization
            @locator = Decidim::ResourceLocatorPresenter.new(@conference)

            add_diploma_attachment

            subject = I18n.t("diploma.subject", scope: "decidim.conferences.mailer.send_conference_diploma_mailer")
            mail(to: user.email, subject:)
          end
        end

        private

        def add_diploma_attachment
          diploma = WickedPdf.new.pdf_from_string(
            render_to_string(pdf: "conference-diploma",
                             template: "decidim/conferences/admin/send_conference_diploma_mailer/diploma_user",
                             layout: "decidim/diploma"),
            orientation: "Landscape"
          )

          attachments["conference-#{@user.nickname.parameterize}-diploma.pdf"] = diploma
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-conferences-0.29.1 app/mailers/decidim/conferences/admin/send_conference_diploma_mailer.rb
decidim-conferences-0.28.4 app/mailers/decidim/conferences/admin/send_conference_diploma_mailer.rb
decidim-conferences-0.29.0 app/mailers/decidim/conferences/admin/send_conference_diploma_mailer.rb
decidim-conferences-0.28.3 app/mailers/decidim/conferences/admin/send_conference_diploma_mailer.rb
decidim-conferences-0.29.0.rc4 app/mailers/decidim/conferences/admin/send_conference_diploma_mailer.rb
decidim-conferences-0.29.0.rc3 app/mailers/decidim/conferences/admin/send_conference_diploma_mailer.rb
decidim-conferences-0.29.0.rc2 app/mailers/decidim/conferences/admin/send_conference_diploma_mailer.rb
decidim-conferences-0.29.0.rc1 app/mailers/decidim/conferences/admin/send_conference_diploma_mailer.rb
decidim-conferences-0.28.2 app/mailers/decidim/conferences/admin/send_conference_diploma_mailer.rb
decidim-conferences-0.28.1 app/mailers/decidim/conferences/admin/send_conference_diploma_mailer.rb
decidim-conferences-0.28.0 app/mailers/decidim/conferences/admin/send_conference_diploma_mailer.rb
decidim-conferences-0.28.0.rc5 app/mailers/decidim/conferences/admin/send_conference_diploma_mailer.rb
decidim-conferences-0.28.0.rc4 app/mailers/decidim/conferences/admin/send_conference_diploma_mailer.rb