Sha256: db3770a1157b4b1ef4207d3414c5ef06e6ce66fc4cf39c85b1426d3b39ccbfdd

Contents?: true

Size: 1.31 KB

Versions: 49

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

49 entries across 49 versions & 1 rubygems

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