Sha256: b3edbb0327bf737c2f108b33c1fc95a99c206bffa0dbd83f92fa78a51f8a35c6

Contents?: true

Size: 1.32 KB

Versions: 7

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    # A command with all the business logic to destroy a participatory space private user.
    class DestroyParticipatorySpacePrivateUser < Decidim::Command
      # Public: Initializes the command.
      #
      # participatory_space_private_user - The participatory space private user to destroy
      # current_user - the user performing the action
      def initialize(participatory_space_private_user, current_user)
        @participatory_space_private_user = participatory_space_private_user
        @current_user = current_user
      end

      # Executes the command. Broadcasts these events:
      #
      # - :ok when everything is valid.
      # - :invalid if the form was not valid and we could not proceed.
      #
      # Returns nothing.
      def call
        destroy_participatory_space_private_user
        broadcast(:ok)
      end

      private

      attr_reader :current_user

      def destroy_participatory_space_private_user
        Decidim.traceability.perform_action!(
          "delete",
          @participatory_space_private_user,
          current_user,
          resource: {
            title: @participatory_space_private_user.user.name
          }
        ) do
          @participatory_space_private_user.destroy!
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-admin-0.28.4 app/commands/decidim/admin/destroy_participatory_space_private_user.rb
decidim-admin-0.28.3 app/commands/decidim/admin/destroy_participatory_space_private_user.rb
decidim-admin-0.28.2 app/commands/decidim/admin/destroy_participatory_space_private_user.rb
decidim-admin-0.28.1 app/commands/decidim/admin/destroy_participatory_space_private_user.rb
decidim-admin-0.28.0 app/commands/decidim/admin/destroy_participatory_space_private_user.rb
decidim-admin-0.28.0.rc5 app/commands/decidim/admin/destroy_participatory_space_private_user.rb
decidim-admin-0.28.0.rc4 app/commands/decidim/admin/destroy_participatory_space_private_user.rb