houdini/app/models/donation.rb
Bradley M. Kuhn 6772312ea7 Relicense all .rb files under new project license.
The primary license of the project is changing to:
  AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later

with some specific files to be licensed under the one of two licenses:
   CC0-1.0
   LGPL-3.0-or-later

This commit is one of the many steps to relicense the entire codebase.

Documentation granting permission for this relicensing (from all past
contributors who hold copyrights) is on file with Software Freedom
Conservancy, Inc.
2018-03-25 15:10:40 -04:00

48 lines
1.4 KiB
Ruby

# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
class Donation < ActiveRecord::Base
attr_accessible \
:date, # datetime (when this donation was made)
:amount, # int (in cents)
:recurring, # bool
:anonymous, # bool
:email, # str (cached email of the donor)
:designation, # text
:dedication, # text
:comment, # text
:origin_url, # text
:nonprofit_id, :nonprofit,
:card_id, :card, # Card with which any charges were made
:supporter_id, :supporter,
:profile_id, :profile,
:campaign_id, :campaign,
:payment_id, :payment,
:event_id, :event,
:direct_debit_detail_id, :direct_debit_detail,
:payment_provider
validates :amount, presence: true, numericality: { only_integer: true }
validates :supporter, presence: true
validates :nonprofit, presence: true
validates_associated :charges
validates :payment_provider, inclusion: { in: %(credit_card sepa) }, allow_blank: true
has_many :charges
has_many :campaign_gifts, dependent: :destroy
has_many :campaign_gift_options, through: :campaign_gifts
has_many :activities, as: :attachment, dependent: :destroy
has_many :payments
has_one :recurring_donation
has_one :payment
has_one :offsite_payment
has_one :tracking
belongs_to :supporter
belongs_to :card
belongs_to :direct_debit_detail
belongs_to :profile
belongs_to :nonprofit
belongs_to :campaign
belongs_to :event
scope :anonymous, -> {where(anonymous: true)}
end