Sha256: 68f321986f3b291e542db03453d23d2236761f53185a4729990fca42d0d08318

Contents?: true

Size: 1023 Bytes

Versions: 63

Compression:

Stored size: 1023 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Budgets
    module Admin
      # This command is executed when the user deletes a Project from the admin
      # panel.
      class DestroyProject < Rectify::Command
        # Initializes an UpdateProject Command.
        #
        # project - The current instance of the project to be destroyed.
        # current_user - the user that performs the action
        def initialize(project, current_user)
          @project = project
          @current_user = current_user
        end

        # Performs the action.
        #
        # Broadcasts :ok if successful, :invalid otherwise.
        def call
          destroy_project
          broadcast(:ok)
        end

        private

        attr_reader :project, :current_user

        def destroy_project
          Decidim.traceability.perform_action!(
            :delete,
            project,
            current_user
          ) do
            project.destroy!
          end
        end
      end
    end
  end
end

Version data entries

63 entries across 63 versions & 1 rubygems

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