Sha256: f287a006efc43af25a6a07a8ada56849b30e4d5f1d580d3def4dcfc9913cf9cd

Contents?: true

Size: 1.47 KB

Versions: 48

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 < Rectify::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

48 entries across 48 versions & 1 rubygems

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