Sha256: 6c9e190d34faf8dc70f47ca90c505688abf2171d01585aaacdbae78991e902e9

Contents?: true

Size: 879 Bytes

Versions: 12

Compression:

Stored size: 879 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_page
        transaction do
          Decidim.traceability.perform_action!(
            "delete",
            topic,
            current_user
          ) do
            topic.destroy!
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
decidim-admin-0.27.9 app/commands/decidim/admin/destroy_static_page_topic.rb
decidim-admin-0.27.8 app/commands/decidim/admin/destroy_static_page_topic.rb
decidim-admin-0.27.7 app/commands/decidim/admin/destroy_static_page_topic.rb
decidim-admin-0.27.6 app/commands/decidim/admin/destroy_static_page_topic.rb
decidim-admin-0.27.5 app/commands/decidim/admin/destroy_static_page_topic.rb
decidim-admin-0.27.4 app/commands/decidim/admin/destroy_static_page_topic.rb
decidim-admin-0.27.3 app/commands/decidim/admin/destroy_static_page_topic.rb
decidim-admin-0.27.2 app/commands/decidim/admin/destroy_static_page_topic.rb
decidim-admin-0.27.1 app/commands/decidim/admin/destroy_static_page_topic.rb
decidim-admin-0.27.0 app/commands/decidim/admin/destroy_static_page_topic.rb
decidim-admin-0.27.0.rc2 app/commands/decidim/admin/destroy_static_page_topic.rb
decidim-admin-0.27.0.rc1 app/commands/decidim/admin/destroy_static_page_topic.rb