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.6.5 app/commands/decidim/admin/create_newsletter.rb
decidim-0.6.5 decidim-admin/app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.6.4 app/commands/decidim/admin/create_newsletter.rb
decidim-0.6.4 decidim-admin/app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.6.3 app/commands/decidim/admin/create_newsletter.rb
decidim-0.6.3 decidim-admin/app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.6.2 app/commands/decidim/admin/create_newsletter.rb
decidim-0.6.2 decidim-admin/app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.6.1 app/commands/decidim/admin/create_newsletter.rb
decidim-0.6.1 decidim-admin/app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.6.0 app/commands/decidim/admin/create_newsletter.rb
decidim-0.6.0 decidim-admin/app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.5.1 app/commands/decidim/admin/create_newsletter.rb
decidim-0.5.1 decidim-admin/app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.5.0 app/commands/decidim/admin/create_newsletter.rb
decidim-0.5.0 decidim-admin/app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.4.4 app/commands/decidim/admin/create_newsletter.rb
decidim-0.4.4 decidim-admin/app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.4.3 app/commands/decidim/admin/create_newsletter.rb
decidim-admin-0.4.2 app/commands/decidim/admin/create_newsletter.rb