Sha256: 0111ccfdf7b48a1a6e38754fb5dcda7e09985fc86fcaede78d4aa1cd0fd60022

Contents?: true

Size: 1.44 KB

Versions: 12

Compression:

Stored size: 1.44 KB

Contents

# frozen_string_literal: true

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

        private

        attr_reader :conference_partner, :current_user

        def destroy_partner!
          log_info = {
            resource: {
              title: conference_partner.name
            },
            participatory_space: {
              title: conference_partner.conference.title
            }
          }

          Decidim.traceability.perform_action!(
            "delete",
            conference_partner,
            current_user,
            log_info
          ) do
            conference_partner.destroy!
            conference_partner
          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_partner.rb
decidim-conferences-0.27.8 app/commands/decidim/conferences/admin/destroy_partner.rb
decidim-conferences-0.27.7 app/commands/decidim/conferences/admin/destroy_partner.rb
decidim-conferences-0.27.6 app/commands/decidim/conferences/admin/destroy_partner.rb
decidim-conferences-0.27.5 app/commands/decidim/conferences/admin/destroy_partner.rb
decidim-conferences-0.27.4 app/commands/decidim/conferences/admin/destroy_partner.rb
decidim-conferences-0.27.3 app/commands/decidim/conferences/admin/destroy_partner.rb
decidim-conferences-0.27.2 app/commands/decidim/conferences/admin/destroy_partner.rb
decidim-conferences-0.27.1 app/commands/decidim/conferences/admin/destroy_partner.rb
decidim-conferences-0.27.0 app/commands/decidim/conferences/admin/destroy_partner.rb
decidim-conferences-0.27.0.rc2 app/commands/decidim/conferences/admin/destroy_partner.rb
decidim-conferences-0.27.0.rc1 app/commands/decidim/conferences/admin/destroy_partner.rb