Sha256: d5bdbb61b86341d6412629e5845c8eb98bcd3906a0519b7525f69073c253edfd

Contents?: true

Size: 789 Bytes

Versions: 31

Compression:

Stored size: 789 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    # Creates a newsletter and assigns the right author and
    # organization.
    class CreateNewsletter < Rectify::Command
      # Initializes the command.
      #
      # form - The source fo data for this newsletter.
      # user - The User that authored this newsletter.
      def initialize(form, user)
        @form = form
        @user = user
      end

      def call
        return broadcast(:invalid) unless @form.valid?

        newsletter = Decidim.traceability.create!(
          Newsletter,
          @user,
          subject: @form.subject,
          body: @form.body,
          author: @user,
          organization: @user.organization
        )

        broadcast(:ok, newsletter)
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
decidim-admin-0.21.0 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.20.1 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.20.0 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.19.1 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.18.1 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.19.0 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.17.2 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.18.0 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.17.1 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.16.1 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.17.0 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.16.0 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.15.2 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.15.1 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.15.0 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.14.4 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.14.3 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.14.2 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.14.1 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.13.1 app/commands/decidim/admin/create_newsletter.rb