Sha256: f56408eecd40b1ee4cc09f21dcbb2721c2d56f20a175949b7b2f9cf734c87ac2

Contents?: true

Size: 984 Bytes

Versions: 25

Compression:

Stored size: 984 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Templates
    module Admin
      # This command deals with destroying a template from the admin panel.
      class DestroyTemplate < Decidim::Command
        # Public: Initializes the command.
        #
        # template - The Template to be destroyed.
        # user        - The user that destroys the template.
        def initialize(template, current_user)
          @template = template
          @current_user = current_user
        end

        # Public: Executes the command.
        #
        # Broadcasts :ok if it got destroyed
        def call
          destroy_template
          broadcast(:ok)
        end

        private

        attr_reader :template, :current_user

        def destroy_template
          Decidim.traceability.perform_action!(
            :delete,
            template,
            current_user
          ) do
            template.destroy!
          end
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
decidim-templates-0.29.1 app/commands/decidim/templates/admin/destroy_template.rb
decidim-templates-0.28.4 app/commands/decidim/templates/admin/destroy_template.rb
decidim-templates-0.27.9 app/commands/decidim/templates/admin/destroy_template.rb
decidim-templates-0.29.0 app/commands/decidim/templates/admin/destroy_template.rb
decidim-templates-0.28.3 app/commands/decidim/templates/admin/destroy_template.rb
decidim-templates-0.27.8 app/commands/decidim/templates/admin/destroy_template.rb
decidim-templates-0.29.0.rc4 app/commands/decidim/templates/admin/destroy_template.rb
decidim-templates-0.29.0.rc3 app/commands/decidim/templates/admin/destroy_template.rb
decidim-templates-0.29.0.rc2 app/commands/decidim/templates/admin/destroy_template.rb
decidim-templates-0.29.0.rc1 app/commands/decidim/templates/admin/destroy_template.rb
decidim-templates-0.28.2 app/commands/decidim/templates/admin/destroy_template.rb
decidim-templates-0.27.7 app/commands/decidim/templates/admin/destroy_template.rb
decidim-templates-0.28.1 app/commands/decidim/templates/admin/destroy_template.rb
decidim-templates-0.27.6 app/commands/decidim/templates/admin/destroy_template.rb
decidim-templates-0.28.0 app/commands/decidim/templates/admin/destroy_template.rb
decidim-templates-0.27.5 app/commands/decidim/templates/admin/destroy_template.rb
decidim-templates-0.28.0.rc5 app/commands/decidim/templates/admin/destroy_template.rb
decidim-templates-0.28.0.rc4 app/commands/decidim/templates/admin/destroy_template.rb
decidim-templates-0.27.4 app/commands/decidim/templates/admin/destroy_template.rb
decidim-templates-0.27.3 app/commands/decidim/templates/admin/destroy_template.rb