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.12.2 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.13.0 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.12.1 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.13.0.pre1 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.12.0 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.11.2 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.12.0.pre app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.11.1 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.11.0.pre1 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.10.1 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.10.0 app/commands/decidim/admin/create_newsletter.rb