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.4.1 app/commands/decidim/admin/create_newsletter.rb
decidim-0.4.3 decidim-admin/app/commands/decidim/admin/create_newsletter.rb
decidim-0.4.2 decidim-admin/app/commands/decidim/admin/create_newsletter.rb
decidim-0.4.1 decidim-admin/app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.4.0 app/commands/decidim/admin/create_newsletter.rb
decidim-0.4.0 decidim-admin/app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.3.2 app/commands/decidim/admin/create_newsletter.rb
decidim-0.3.2 decidim-admin/app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.3.1 app/commands/decidim/admin/create_newsletter.rb
decidim-0.3.1 decidim-admin/app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.3.0 app/commands/decidim/admin/create_newsletter.rb
decidim-0.3.0 decidim-admin/app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.2.0 app/commands/decidim/admin/create_newsletter.rb
decidim-0.2.0 decidim-admin/app/commands/decidim/admin/create_newsletter.rb