Sha256: e11c85f8dcac729f95b1550a73abc70bb6d0158921961ca3b9bb117181515f60

Contents?: true

Size: 858 Bytes

Versions: 20

Compression:

Stored size: 858 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    # This command deals with destroying a StaticPage from the admin panel.
    class DestroyStaticPage < Decidim::Command
      # Public: Initializes the command.
      #
      # page - The StaticPage to be destroyed.
      def initialize(page, current_user)
        @page = page
        @current_user = current_user
      end

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

      private

      attr_reader :page, :current_user

      def destroy_page
        transaction do
          Decidim.traceability.perform_action!(
            "delete",
            page,
            current_user
          ) do
            page.destroy!
          end
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
decidim-admin-0.28.5 app/commands/decidim/admin/destroy_static_page.rb
decidim-admin-0.28.4 app/commands/decidim/admin/destroy_static_page.rb
decidim-admin-0.27.9 app/commands/decidim/admin/destroy_static_page.rb
decidim-admin-0.28.3 app/commands/decidim/admin/destroy_static_page.rb
decidim-admin-0.27.8 app/commands/decidim/admin/destroy_static_page.rb
decidim-admin-0.28.2 app/commands/decidim/admin/destroy_static_page.rb
decidim-admin-0.27.7 app/commands/decidim/admin/destroy_static_page.rb
decidim-admin-0.28.1 app/commands/decidim/admin/destroy_static_page.rb
decidim-admin-0.27.6 app/commands/decidim/admin/destroy_static_page.rb
decidim-admin-0.28.0 app/commands/decidim/admin/destroy_static_page.rb
decidim-admin-0.27.5 app/commands/decidim/admin/destroy_static_page.rb
decidim-admin-0.28.0.rc5 app/commands/decidim/admin/destroy_static_page.rb
decidim-admin-0.28.0.rc4 app/commands/decidim/admin/destroy_static_page.rb
decidim-admin-0.27.4 app/commands/decidim/admin/destroy_static_page.rb
decidim-admin-0.27.3 app/commands/decidim/admin/destroy_static_page.rb
decidim-admin-0.27.2 app/commands/decidim/admin/destroy_static_page.rb
decidim-admin-0.27.1 app/commands/decidim/admin/destroy_static_page.rb
decidim-admin-0.27.0 app/commands/decidim/admin/destroy_static_page.rb
decidim-admin-0.27.0.rc2 app/commands/decidim/admin/destroy_static_page.rb
decidim-admin-0.27.0.rc1 app/commands/decidim/admin/destroy_static_page.rb