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