Sha256: 84fdc122709a3a823f98a7636ae3634fbaf322b5473db99c9390a629172364c4

Contents?: true

Size: 924 Bytes

Versions: 19

Compression:

Stored size: 924 Bytes

Contents

# frozen_string_literal: true

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

      # Public: Executes the command.
      #
      # Broadcasts :ok if it got destroyed
      def call
        return broadcast(:already_sent) if newsletter.sent?

        destroy_newsletter
        broadcast(:ok)
      end

      private

      attr_reader :newsletter, :current_user

      def destroy_newsletter
        Decidim.traceability.perform_action!(
          "delete",
          newsletter,
          current_user
        ) do
          newsletter.destroy!
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

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