Sha256: ffbdfe520d843929ffdd14d565aef0b756f32ce1fc3bd8e708112843ccb85caf

Contents?: true

Size: 1.59 KB

Versions: 12

Compression:

Stored size: 1.59 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: 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

12 entries across 12 versions & 1 rubygems

Version Path
decidim-conferences-0.27.9 app/mailers/decidim/conferences/admin/send_conference_diploma_mailer.rb
decidim-conferences-0.27.8 app/mailers/decidim/conferences/admin/send_conference_diploma_mailer.rb
decidim-conferences-0.27.7 app/mailers/decidim/conferences/admin/send_conference_diploma_mailer.rb
decidim-conferences-0.27.6 app/mailers/decidim/conferences/admin/send_conference_diploma_mailer.rb
decidim-conferences-0.27.5 app/mailers/decidim/conferences/admin/send_conference_diploma_mailer.rb
decidim-conferences-0.27.4 app/mailers/decidim/conferences/admin/send_conference_diploma_mailer.rb
decidim-conferences-0.27.3 app/mailers/decidim/conferences/admin/send_conference_diploma_mailer.rb
decidim-conferences-0.27.2 app/mailers/decidim/conferences/admin/send_conference_diploma_mailer.rb
decidim-conferences-0.27.1 app/mailers/decidim/conferences/admin/send_conference_diploma_mailer.rb
decidim-conferences-0.27.0 app/mailers/decidim/conferences/admin/send_conference_diploma_mailer.rb
decidim-conferences-0.27.0.rc2 app/mailers/decidim/conferences/admin/send_conference_diploma_mailer.rb
decidim-conferences-0.27.0.rc1 app/mailers/decidim/conferences/admin/send_conference_diploma_mailer.rb