Sha256: 512a6652bbd208ebb33a27cdd92f7a7b08bd897dc940559229b1dd4e07a5b6a2
Contents?: true
Size: 1.82 KB
Versions: 1
Compression:
Stored size: 1.82 KB
Contents
class MembershipType < ActiveRecord::Base attr_accessible :name, :price, :fee, :number_of_shows, :plan, :on_sale, :description, :ends_at, :starts_at, :duration, :type, :period, :number_of_tickets, :sales_start_at, :sales_end_at, :thanks_copy, :invitation_email_text_copy, :hide_fee, :renewal_price, :offer_renewal belongs_to :organization has_many :memberships has_many :members, :through => :memberships belongs_to :segment after_create :create_list_segment validates :name, :description, :price, :presence => true scope :storefront, where(:on_sale => true).where("sales_start_at < ? or sales_start_at is null", DateTime.now).where("sales_end_at > ? or sales_end_at is null", DateTime.now) scope :on_sale, where(:on_sale => true) scope :not_ended, where('ends_at > ?', DateTime.now) SERVICE_FEE = 0.05 comma do name description price fee number_of_tickets type memberships 'Memberships sold' do |m| m.count end members { |m| m.distinct(:member_id).count } duration period starts_at ends_at on_sale sales_start_at sales_end_at end def self.in_play(organization) self.find((organization.membership_types.not_ended.pluck(:id).uniq + organization.memberships.current.select(:membership_type_id).uniq.pluck(:membership_type_id))) end def membershipize self.name.end_with?("Membership") ? self.name : self.name + " Membership" end def price_for(member = nil) return price if member.nil? (offer_renewal? && member.current?) ? renewal_price : price end def create_list_segment @search = organization.searches.create({:membership_type => self}) @segment = organization.segments.create({:search => @search, :name => self.name}) self.segment = @segment save end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
artfully_ose-1.2.0.pre.23 | app/models/membership_type.rb |