Class: Decidim::Newsletter
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Decidim::Newsletter
- Includes:
- Loggable, Traceable, TranslatableResource
- Defined in:
- app/models/decidim/newsletter.rb
Overview
This model holds all the data needed to send a newsletter.
Class Method Summary collapse
Instance Method Summary collapse
- #sended_to_all_users? ⇒ Boolean
- #sended_to_followers? ⇒ Boolean
- #sended_to_participants? ⇒ Boolean
- #sended_to_partipatory_spaces ⇒ Object
-
#sent? ⇒ Boolean
Returns true if this newsletter was already sent.
- #sent_scopes ⇒ Object
- #sent_scopes_ids ⇒ Object
- #template ⇒ Object
Class Method Details
.log_presenter_class_for(_log) ⇒ Object
18 19 20 |
# File 'app/models/decidim/newsletter.rb', line 18 def self.log_presenter_class_for(_log) Decidim::AdminLog::NewsletterPresenter end |
Instance Method Details
#sended_to_all_users? ⇒ Boolean
37 38 39 |
# File 'app/models/decidim/newsletter.rb', line 37 def sended_to_all_users? extended_data["send_to_all_users"] end |
#sended_to_followers? ⇒ Boolean
41 42 43 |
# File 'app/models/decidim/newsletter.rb', line 41 def sended_to_followers? extended_data["send_to_followers"] end |
#sended_to_participants? ⇒ Boolean
45 46 47 |
# File 'app/models/decidim/newsletter.rb', line 45 def sended_to_participants? extended_data["send_to_participants"] end |
#sended_to_partipatory_spaces ⇒ Object
49 50 51 |
# File 'app/models/decidim/newsletter.rb', line 49 def sended_to_partipatory_spaces extended_data["participatory_space_types"] end |
#sent? ⇒ Boolean
Returns true if this newsletter was already sent.
Returns a Boolean.
25 26 27 |
# File 'app/models/decidim/newsletter.rb', line 25 def sent? sent_at.present? end |
#sent_scopes ⇒ Object
33 34 35 |
# File 'app/models/decidim/newsletter.rb', line 33 def sent_scopes @sent_scopes ||= organization.scopes.where(id: sent_scopes_ids) end |
#sent_scopes_ids ⇒ Object
29 30 31 |
# File 'app/models/decidim/newsletter.rb', line 29 def sent_scopes_ids extended_data["scope_ids"] || [] end |
#template ⇒ Object
53 54 55 56 57 |
# File 'app/models/decidim/newsletter.rb', line 53 def template @template ||= Decidim::ContentBlock .for_scope(:newsletter_template, organization: organization) .find_by(scoped_resource_id: id) end |