Sha256: 1ee72f95bf43e2b01e9f4da80f48c511dadf0913f9a1d1fed83d3317f582e8b6

Contents?: true

Size: 888 Bytes

Versions: 18

Compression:

Stored size: 888 Bytes

Contents

class OrderView < ActiveRecord::Base
  self.table_name = 'order_view'
  self.primary_key = 'id'
  has_many :items, :foreign_key => 'order_id'
  
  default_scope :order => 'created_at DESC'
  scope :before, lambda { |time| where("created_at < ?", time) }
  scope :after,  lambda { |time| where("created_at > ?", time) }
  scope :imported, where("fa_id IS NOT NULL")
  scope :not_imported, where("fa_id IS NULL")
  scope :artfully, where("transaction_id IS NOT NULL")
  
  set_watch_for :created_at, :local_to => :self, :as => :admins
  
  def artfully?
    !transaction_id.nil?
  end


  #
  # If we can push these into the view (with an SQL case) then we can save having to join to items in Ruby
  #
  def has_ticket?
    items.select(&:ticket?).present?
  end

  def has_donation?
    items.select(&:donation?).present?
  end
  
  def time_zone
    "Eastern Time (US & Canada)"
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
artfully_ose-1.2.0.pre.19 app/models/database_views/order_view.rb
artfully_ose-1.2.0.pre.18 app/models/database_views/order_view.rb
artfully_ose-1.2.0.pre.17 app/models/database_views/order_view.rb
artfully_ose-1.2.0.pre.16 app/models/database_views/order_view.rb
artfully_ose-1.2.0.pre.15 app/models/database_views/order_view.rb
artfully_ose-1.2.0.pre.12 app/models/database_views/order_view.rb
artfully_ose-1.2.0.pre.11 app/models/database_views/order_view.rb
artfully_ose-1.2.0.pre.10 app/models/database_views/order_view.rb
artfully_ose-1.2.0.pre.9 app/models/database_views/order_view.rb
artfully_ose-1.2.0.pre.8 app/models/database_views/order_view.rb
artfully_ose-1.2.0.pre.7 app/models/database_views/order_view.rb
artfully_ose-1.2.0.pre.6 app/models/database_views/order_view.rb
artfully_ose-1.2.0.pre.5 app/models/database_views/order_view.rb
artfully_ose-1.2.0.pre.4 app/models/database_views/order_view.rb
artfully_ose-1.2.0.pre.3 app/models/database_views/order_view.rb
artfully_ose-1.2.0.pre.2 app/models/database_views/order_view.rb
artfully_ose-1.2.0.pre.1 app/models/database_views/order_view.rb
artfully_ose-1.2.0.pre app/models/database_views/order_view.rb