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
- #notifications_settings_url ⇒ Object
 - #organization_official_url ⇒ Object
 - #sended_to_all_users? ⇒ Boolean
 - #sended_to_followers? ⇒ Boolean
 - #sended_to_participants? ⇒ Boolean
 - 
  
    
      #sent?  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
Returns true if this newsletter was already sent.
 - #sent_scopes ⇒ Object
 - #sent_scopes_ids ⇒ Object
 - #sent_to_participatory_spaces ⇒ Object
 - #template ⇒ Object
 - #unsubscribe_newsletters_url ⇒ Object
 - #url ⇒ 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
#notifications_settings_url ⇒ Object
      63 64 65  | 
    
      # File 'app/models/decidim/newsletter.rb', line 63 def notifications_settings_url(**) proxy_url(__method__, **) end  | 
  
#organization_official_url ⇒ Object
      71 72 73 74 75  | 
    
      # File 'app/models/decidim/newsletter.rb', line 71 def organization_official_url return "#" unless sent? organization.official_url || proxy_url(:root_url) end  | 
  
#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  | 
  
#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  | 
  
#sent_to_participatory_spaces ⇒ Object
      49 50 51  | 
    
      # File 'app/models/decidim/newsletter.rb', line 49 def sent_to_participatory_spaces extended_data["participatory_space_types"] 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:) .find_by(scoped_resource_id: id) end  | 
  
#unsubscribe_newsletters_url ⇒ Object
      67 68 69  | 
    
      # File 'app/models/decidim/newsletter.rb', line 67 def (**) proxy_url(__method__, **) end  | 
  
#url ⇒ Object
      59 60 61  | 
    
      # File 'app/models/decidim/newsletter.rb', line 59 def url(**) proxy_url(:newsletter_url, id:, **) end  |