Sha256: a4d47aae8384f05de8e861bda6899748c59549f047bc51781e220a556fa8eb24

Contents?: true

Size: 880 Bytes

Versions: 8

Compression:

Stored size: 880 Bytes

Contents

# frozen_string_literal: true

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

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

      private

      attr_reader :page, :current_user

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
decidim-admin-0.28.5 app/commands/decidim/admin/destroy_static_page_topic.rb
decidim-admin-0.28.4 app/commands/decidim/admin/destroy_static_page_topic.rb
decidim-admin-0.28.3 app/commands/decidim/admin/destroy_static_page_topic.rb
decidim-admin-0.28.2 app/commands/decidim/admin/destroy_static_page_topic.rb
decidim-admin-0.28.1 app/commands/decidim/admin/destroy_static_page_topic.rb
decidim-admin-0.28.0 app/commands/decidim/admin/destroy_static_page_topic.rb
decidim-admin-0.28.0.rc5 app/commands/decidim/admin/destroy_static_page_topic.rb
decidim-admin-0.28.0.rc4 app/commands/decidim/admin/destroy_static_page_topic.rb