Sha256: 9aa3c7e6a281da44a70b441331fa65d32e94192db7bcb5f11b640428c45d5035

Contents?: true

Size: 1.18 KB

Versions: 5

Compression:

Stored size: 1.18 KB

Contents

# A +Renderable+ which "offers" the user something.  Responses to these
# offers are tracked as +Leads+
#
class Offer < Renderable
  has_many :deals, :inverse_of => :offer
  has_many :leads, :class_name => 'Deal', :conditions => ["deals.status = ?", Deal::Status::Lead]

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

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

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

  mount_uploader :file, FileUploader

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

  def to_s
    name
  end

  def as_json(options={})
    {}.tap do |hash|
      hash[:id]       = self.id,
      hash[:name]     = self.name,
      hash[:template] = self.template,
      hash[:errors]   = self.errors
    end
  end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
e9_crm-0.1.7 app/models/offer.rb
e9_crm-0.1.6 app/models/offer.rb
e9_crm-0.1.5 app/models/offer.rb
e9_crm-0.1.4 app/models/offer.rb
e9_crm-0.1.1 app/models/offer.rb