Sha256: 5aa9f980339180fe9a0f2570814552e067a3aa56e9531eb807e077429653cb70

Contents?: true

Size: 1.37 KB

Versions: 8

Compression:

Stored size: 1.37 KB

Contents

# A +Renderable+ which "offers" the user something.  Responses to these
# offers are tracked as +Leads+
#
class Offer < Renderable
  include E9Rails::ActiveRecord::STI
  include E9Rails::ActiveRecord::Initialization
  include E9Rails::ActiveRecord::InheritableOptions

  has_many :deals, :inverse_of => :offer
  has_many :leads, :class_name => 'Deal', :conditions => ["deals.status = ?", Deal::Status::Lead]

  validates :conversion_alert_email, :email => { :allow_blank => true }

  mount_uploader :file, FileUploader

  self.delegate_options_methods = true
  self.options_parameters = [
    :submit_button_text,
    :success_alert_text,
    :success_page_text,
    :download_link_text,
    :conversion_alert_email,
    :custom_form_html
  ]

  class << self
    def conversion_email
      SystemEmail.find_by_identifier(Identifiers::CONVERSION_EMAIL)
    end

    def page
      SystemPage.find_by_identifier(Identifiers::PAGE)
    end

    def partial_path
      'e9_crm/offers/offer'
    end

    def element
      'offer'
    end
  end

  def to_s
    name
  end


  protected

    def _assign_initialization_defaults
      self.submit_button_text ||= 'Submit!'
      self.download_link_text ||= 'Click to download your file'
      self.success_page_text  ||= 'Thank you!'
    end

  module Identifiers
    CONVERSION_EMAIL = 'offer_conversion_email'
    PAGE             = 'offer_page'
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
e9_crm-0.1.17 app/models/offer.rb
e9_crm-0.1.16 app/models/offer.rb
e9_crm-0.1.14 app/models/offer.rb
e9_crm-0.1.13 app/models/offer.rb
e9_crm-0.1.12 app/models/offer.rb
e9_crm-0.1.11 app/models/offer.rb
e9_crm-0.1.10 app/models/offer.rb
e9_crm-0.1.8 app/models/offer.rb