app/models/discount.rb in artfully_ose-1.1.0 vs app/models/discount.rb in artfully_ose-1.2.0.alpha.1
- old
+ new
@@ -1,11 +1,11 @@
class Discount < ActiveRecord::Base
require 'set'
attr_accessible :active, :code, :promotion_type, :event,
:organization, :creator, :properties,
- :minimum_ticket_count, :show_ids, :sections,
+ :minimum_ticket_count, :show_ids, :ticket_types,
:limit
attr_accessor :cart
include OhNoes::Destroy
@@ -15,21 +15,21 @@
belongs_to :organization
belongs_to :creator, :class_name => "User", :foreign_key => "user_id"
has_and_belongs_to_many :shows
accepts_nested_attributes_for :shows
- serialize :sections, Set
+ serialize :ticket_types, Set
validates_presence_of :code, :promotion_type, :event, :organization, :creator
validates :code, :length => { :minimum => 4, :maximum => 15, :allow_blank => true }, :uniqueness => {:scope => :event_id}
validates_numericality_of :limit, :minimum_ticket_count, :only_integer => true, :allow_blank => true
serialize :properties, HashWithIndifferentAccess
before_validation :set_organization_from_event
before_validation :ensure_properties_are_set
- before_validation :cast_sections_to_clean_set
+ before_validation :cast_ticket_types_to_clean_set
before_destroy :ensure_discount_is_destroyable
has_many :tickets
has_many :items
@@ -85,11 +85,11 @@
def minimum_ticket_count
self[:minimum_ticket_count] || 0
end
def clear_existing_discount
- @cart.reset_prices_on_tickets
+ @cart.prepare_for_discount!
end
def redeemed
tickets.count
end
@@ -128,10 +128,10 @@
"#{self.promotion_type}DiscountType".constantize
rescue NameError
raise "#{self.promotion_type} Discount Type has not been defined!"
end
- def cast_sections_to_clean_set
- self[:sections] = Set.new(self[:sections]) unless self[:sections].kind_of?(Set)
- self[:sections].reject!{|s| s.blank? }
+ def cast_ticket_types_to_clean_set
+ self[:ticket_types] = Set.new(self[:ticket_types]) unless self[:ticket_types].kind_of?(Set)
+ self[:ticket_types].reject!{|s| s.blank? }
end
end