Class: Decidim::Newsletter

Inherits:
ApplicationRecord show all
Includes:
Loggable, Traceable
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



15
16
17
# File 'app/models/decidim/newsletter.rb', line 15

def self.log_presenter_class_for(_log)
  Decidim::AdminLog::NewsletterPresenter
end

Instance Method Details

#sended_to_all_users?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'app/models/decidim/newsletter.rb', line 34

def sended_to_all_users?
  extended_data["send_to_all_users"]
end

#sended_to_followers?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'app/models/decidim/newsletter.rb', line 38

def sended_to_followers?
  extended_data["send_to_followers"]
end

#sended_to_participants?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'app/models/decidim/newsletter.rb', line 42

def sended_to_participants?
  extended_data["send_to_participants"]
end

#sended_to_partipatory_spacesObject



46
47
48
# File 'app/models/decidim/newsletter.rb', line 46

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)


22
23
24
# File 'app/models/decidim/newsletter.rb', line 22

def sent?
  sent_at.present?
end

#sent_scopesObject



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

def sent_scopes
  @sent_scopes ||= organization.scopes.where(id: sent_scopes_ids)
end

#sent_scopes_idsObject



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

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