Class: Decidim::Newsletter

Inherits:
ApplicationRecord show all
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

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

Returns:

  • (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

Returns:

  • (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

Returns:

  • (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_spacesObject



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.

Returns:

  • (Boolean)


25
26
27
# File 'app/models/decidim/newsletter.rb', line 25

def sent?
  sent_at.present?
end

#sent_scopesObject



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_idsObject



29
30
31
# File 'app/models/decidim/newsletter.rb', line 29

def sent_scopes_ids
  extended_data["scope_ids"] || []
end

#templateObject



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