Class: AlchemyCrm::Newsletter
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- AlchemyCrm::Newsletter
- Defined in:
- app/models/alchemy_crm/newsletter.rb
Instance Method Summary collapse
- #can_delete_mailings? ⇒ Boolean
- #contacts ⇒ Object
- #contacts_count ⇒ Object
- #humanized_name ⇒ Object
- #layout_name ⇒ Object
-
#verified_contact_group_contacts ⇒ Object
get all uniq contacts from my contact groups.
- #verified_subscribers ⇒ Object
Instance Method Details
#can_delete_mailings? ⇒ Boolean
39 40 41 |
# File 'app/models/alchemy_crm/newsletter.rb', line 39 def can_delete_mailings? raise "Cannot delete Newsletter because of referencing Mailings with IDs (#{mailings.collect(&:id).join(", ")})" if(mailings.length != 0) end |
#contacts ⇒ Object
17 18 19 |
# File 'app/models/alchemy_crm/newsletter.rb', line 17 def contacts (verified_contact_group_contacts + verified_subscribers).uniq end |
#contacts_count ⇒ Object
21 22 23 24 |
# File 'app/models/alchemy_crm/newsletter.rb', line 21 def contacts_count return 0 if contacts.blank? contacts.length end |
#humanized_name ⇒ Object
31 32 33 |
# File 'app/models/alchemy_crm/newsletter.rb', line 31 def humanized_name "#{name} (#{contacts_count})" end |
#layout_name ⇒ Object
43 44 45 |
# File 'app/models/alchemy_crm/newsletter.rb', line 43 def layout_name NewsletterLayout.display_name_for(layout) end |
#verified_contact_group_contacts ⇒ Object
get all uniq contacts from my contact groups
27 28 29 |
# File 'app/models/alchemy_crm/newsletter.rb', line 27 def verified_contact_group_contacts contact_groups.collect { |contact_group| contact_group.contacts.available }.flatten.uniq end |
#verified_subscribers ⇒ Object
35 36 37 |
# File 'app/models/alchemy_crm/newsletter.rb', line 35 def verified_subscribers subscribers.available.includes(:subscriptions).where(:alchemy_crm_subscriptions => {:verified => true, :wants => true}) end |