Sha256: b51df3d4b5e0d7f81838472972d412e6306810f18fa968df5461796721ded092

Contents?: true

Size: 1.47 KB

Versions: 12

Compression:

Stored size: 1.47 KB

Contents

# frozen_string_literal: true

module Decidim
  module Conferences
    module Admin
      # A command with all the business logic when destroying an conference
      # speaker in the system.
      class DestroyConferenceSpeaker < Decidim::Command
        # Public: Initializes the command.
        #
        # conference_speaker - the ConferenceSpeaker to destroy
        # current_user - the user performing this action
        def initialize(conference_speaker, current_user)
          @conference_speaker = conference_speaker
          @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
          destroy_speaker!
          broadcast(:ok)
        end

        private

        attr_reader :conference_speaker, :current_user

        def destroy_speaker!
          log_info = {
            resource: {
              title: conference_speaker.full_name
            },
            participatory_space: {
              title: conference_speaker.conference.title
            }
          }

          Decidim.traceability.perform_action!(
            "delete",
            conference_speaker,
            current_user,
            log_info
          ) do
            conference_speaker.destroy!
            conference_speaker
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

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