Sha256: 12b928bfb9393d1f64a826bba7a248209a1e1d59597d3e621838b099c6db5c82

Contents?: true

Size: 1.24 KB

Versions: 29

Compression:

Stored size: 1.24 KB

Contents

class RegularDonationKit < Kit
  acts_as_kit :with_approval => true do
    activate :if => :has_tax_info?
    activate :if => :exclusive?
    approve :unless => :no_bank_account?

    when_active do |organization|
      organization.can :receive, Donation
    end
  end

  def has_tax_info?
    errors.add(:requirements, "Your organization's tax information is missing or incomplete. Please complete it in order to active this kit.") unless organization.has_tax_info?
    organization.has_tax_info?
  end
  
  def friendly_name
    "Charity Donations"
  end
  
  def pitch
    "Receive donations for a 501(c)(3)"
  end

  def exclusive?
    exclusive = !organization.kits.where(:type => alternatives.collect(&:to_s)).any?
    errors.add(:requirements, "You have already activated a mutually exclusive kit.") unless exclusive
    exclusive
  end

  def no_bank_account?
    errors.add(:requirements, "Your organization needs bank account information first.") if organization.bank_account.nil?
    organization.bank_account.nil?
  end

  # def alternatives
  #   @alternatives ||= [ SponsoredDonationKit ]
  # end

  def on_pending
    AdminMailer.donation_kit_notification(self).deliver
    ProducerMailer.donation_kit_notification(self, organization.owner).deliver
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
artfully_ose-1.2.0.pre.3 app/models/kits/regular_donation_kit.rb
artfully_ose-1.2.0.pre.2 app/models/kits/regular_donation_kit.rb
artfully_ose-1.2.0.pre.1 app/models/kits/regular_donation_kit.rb
artfully_ose-1.2.0.pre app/models/kits/regular_donation_kit.rb
artfully_ose-1.1.0 app/models/kits/regular_donation_kit.rb
artfully_ose-1.1.0.rc2 app/models/kits/regular_donation_kit.rb
artfully_ose-1.1.0.rc1 app/models/kits/regular_donation_kit.rb
artfully_ose-1.0.0.rc4 app/models/kits/regular_donation_kit.rb
artfully_ose-1.0.0.rc3 app/models/kits/regular_donation_kit.rb