Sha256: 136d73bf54c27e58b2320a92b14b99197b1e4d33beb5d88bd67d108765e14bba

Contents?: true

Size: 1.31 KB

Versions: 12

Compression:

Stored size: 1.31 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 wasn't valid and we couldn't 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

12 entries across 12 versions & 1 rubygems

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