Sha256: 08e92ef71d1ff96ea8ded1ad8e417906f1d99c2bf685426cd633726bf46cfdb3

Contents?: true

Size: 1.28 KB

Versions: 46

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

module Decidim
  module Conferences
    module Admin
      # A command with all the business logic to send diplomas to registered conference users.
      #
      class SendConferenceDiplomas < Rectify::Command
        # Public: Initializes the command.
        #
        # conference      - The conference which the user is invited to.
        def initialize(conference, current_user)
          @conference = conference
          @current_user = current_user
        end

        # Executes the command. Broadcasts these events:
        #
        # - :ok when everything is valid.
        # - :invalid if the form wasn't valid and we couldn't proceed.
        #
        # Returns nothing.
        def call
          return broadcast(:invalid) if conference.diploma_sent?

          send_diplomas
          broadcast(:ok)
        end

        private

        attr_reader :current_user, :conference

        def send_diplomas
          Decidim.traceability.perform_action!(
            :send_conference_diplomas,
            conference,
            current_user
          ) do
            SendConferenceDiplomaJob.perform_later(conference)
            conference.diploma_sent_at = Time.current
            conference.save!
          end
        end
      end
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
decidim-conferences-0.26.10 app/commands/decidim/conferences/admin/send_conference_diplomas.rb
decidim-conferences-0.26.9 app/commands/decidim/conferences/admin/send_conference_diplomas.rb
decidim-conferences-0.26.8 app/commands/decidim/conferences/admin/send_conference_diplomas.rb
decidim-conferences-0.26.7 app/commands/decidim/conferences/admin/send_conference_diplomas.rb
decidim-conferences-0.26.5 app/commands/decidim/conferences/admin/send_conference_diplomas.rb
decidim-conferences-0.26.4 app/commands/decidim/conferences/admin/send_conference_diplomas.rb
decidim-conferences-0.26.3 app/commands/decidim/conferences/admin/send_conference_diplomas.rb
decidim-conferences-0.26.2 app/commands/decidim/conferences/admin/send_conference_diplomas.rb
decidim-conferences-0.26.1 app/commands/decidim/conferences/admin/send_conference_diplomas.rb
decidim-conferences-0.26.0 app/commands/decidim/conferences/admin/send_conference_diplomas.rb
decidim-conferences-0.26.0.rc2 app/commands/decidim/conferences/admin/send_conference_diplomas.rb
decidim-conferences-0.26.0.rc1 app/commands/decidim/conferences/admin/send_conference_diplomas.rb
decidim-conferences-0.25.2 app/commands/decidim/conferences/admin/send_conference_diplomas.rb
decidim-conferences-0.25.1 app/commands/decidim/conferences/admin/send_conference_diplomas.rb
decidim-conferences-0.25.0 app/commands/decidim/conferences/admin/send_conference_diplomas.rb
decidim-conferences-0.25.0.rc4 app/commands/decidim/conferences/admin/send_conference_diplomas.rb
decidim-conferences-0.25.0.rc3 app/commands/decidim/conferences/admin/send_conference_diplomas.rb
decidim-conferences-0.25.0.rc2 app/commands/decidim/conferences/admin/send_conference_diplomas.rb
decidim-conferences-0.25.0.rc1 app/commands/decidim/conferences/admin/send_conference_diplomas.rb
decidim-conferences-0.24.3 app/commands/decidim/conferences/admin/send_conference_diplomas.rb