Sha256: 0ef2274441f92dd99394742e0210cef4a2bc0f16a728b7b6c4ae70bc42bc97d3

Contents?: true

Size: 740 Bytes

Versions: 54

Compression:

Stored size: 740 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 = Newsletter.create!(
          subject: @form.subject,
          body: @form.body,
          author: @user,
          organization: @user.organization
        )

        broadcast(:ok, newsletter)
      end
    end
  end
end

Version data entries

54 entries across 54 versions & 2 rubygems

Version Path
decidim-admin-0.9.3 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.9.2 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.9.1 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.9.0 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.8.4 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.8.3 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.8.2 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.8.1 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.8.0 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.7.4 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.7.3 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.7.2 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.7.1 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.7.0 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.6.8 app/commands/decidim/admin/create_newsletter.rb
decidim-0.6.8 decidim-admin/app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.6.7 app/commands/decidim/admin/create_newsletter.rb
decidim-0.6.7 decidim-admin/app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.6.6 app/commands/decidim/admin/create_newsletter.rb
decidim-0.6.6 decidim-admin/app/commands/decidim/admin/create_newsletter.rb