Class: Decidim::Admin::CreateNewsletter
- Inherits:
-
Rectify::Command
- Object
- Rectify::Command
- Decidim::Admin::CreateNewsletter
- Defined in:
- app/commands/decidim/admin/create_newsletter.rb
Overview
Creates a newsletter and assigns the right author and organization.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(form, user) ⇒ CreateNewsletter
constructor
Initializes the command.
Constructor Details
#initialize(form, user) ⇒ CreateNewsletter
Initializes the command.
form - The source fo data for this newsletter. user - The User that authored this newsletter.
12 13 14 15 |
# File 'app/commands/decidim/admin/create_newsletter.rb', line 12 def initialize(form, user) @form = form @user = user end |
Instance Method Details
#call ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/commands/decidim/admin/create_newsletter.rb', line 17 def call return broadcast(:invalid) unless @form.valid? = Decidim.traceability.create!( Newsletter, @user, subject: @form.subject, body: @form.body, author: @user, organization: @user.organization ) broadcast(:ok, ) end |