Sha256: b3bfb44f0344fd356a1ede6bd2239f85a7f08924640f74d3697ae62052da47f4

Contents?: true

Size: 1.47 KB

Versions: 46

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 a conference
      # registration type in the system.
      class DestroyRegistrationType < Rectify::Command
        # Public: Initializes the command.
        #
        # registration_type - the Partner to destroy
        # current_user - the user performing this action
        def initialize(registration_type, current_user)
          @registration_type = registration_type
          @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_registration_type!
          broadcast(:ok)
        end

        private

        attr_reader :registration_type, :current_user

        def destroy_registration_type!
          log_info = {
            resource: {
              title: registration_type.title
            },
            participatory_space: {
              title: registration_type.conference.title
            }
          }

          Decidim.traceability.perform_action!(
            "delete",
            registration_type,
            current_user,
            log_info
          ) do
            registration_type.destroy!
            registration_type
          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/destroy_registration_type.rb
decidim-conferences-0.26.9 app/commands/decidim/conferences/admin/destroy_registration_type.rb
decidim-conferences-0.26.8 app/commands/decidim/conferences/admin/destroy_registration_type.rb
decidim-conferences-0.26.7 app/commands/decidim/conferences/admin/destroy_registration_type.rb
decidim-conferences-0.26.5 app/commands/decidim/conferences/admin/destroy_registration_type.rb
decidim-conferences-0.26.4 app/commands/decidim/conferences/admin/destroy_registration_type.rb
decidim-conferences-0.26.3 app/commands/decidim/conferences/admin/destroy_registration_type.rb
decidim-conferences-0.26.2 app/commands/decidim/conferences/admin/destroy_registration_type.rb
decidim-conferences-0.26.1 app/commands/decidim/conferences/admin/destroy_registration_type.rb
decidim-conferences-0.26.0 app/commands/decidim/conferences/admin/destroy_registration_type.rb
decidim-conferences-0.26.0.rc2 app/commands/decidim/conferences/admin/destroy_registration_type.rb
decidim-conferences-0.26.0.rc1 app/commands/decidim/conferences/admin/destroy_registration_type.rb
decidim-conferences-0.25.2 app/commands/decidim/conferences/admin/destroy_registration_type.rb
decidim-conferences-0.25.1 app/commands/decidim/conferences/admin/destroy_registration_type.rb
decidim-conferences-0.25.0 app/commands/decidim/conferences/admin/destroy_registration_type.rb
decidim-conferences-0.25.0.rc4 app/commands/decidim/conferences/admin/destroy_registration_type.rb
decidim-conferences-0.25.0.rc3 app/commands/decidim/conferences/admin/destroy_registration_type.rb
decidim-conferences-0.25.0.rc2 app/commands/decidim/conferences/admin/destroy_registration_type.rb
decidim-conferences-0.25.0.rc1 app/commands/decidim/conferences/admin/destroy_registration_type.rb
decidim-conferences-0.24.3 app/commands/decidim/conferences/admin/destroy_registration_type.rb