Sha256: 6ac8d5e306a38e603943b6c094fd29e6b88e0d995e99f7463e122dbb528e48a4

Contents?: true

Size: 984 Bytes

Versions: 33

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

33 entries across 33 versions & 1 rubygems

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