Sha256: 7359514724061f38e081965d754febbc57178dc9d141c1ba746db5011249bb25

Contents?: true

Size: 817 Bytes

Versions: 3

Compression:

Stored size: 817 Bytes

Contents

# Used on the Event Registrations purchases step

class EffectiveEventPurchasesDatatable < Effective::Datatable
  datatable do

    col :event_product, search: :string
    col :price, as: :price
    col :notes
    # no actions_col
  end

  collection do
    scope = Effective::EventPurchase.deep.all

    if event.present?
      scope = scope.where(event: event)
    end

    if event_registration.present?
      scope = scope.where(event_registration_id: event_registration)
    end

    scope
  end

  def event
    @event ||= if attributes[:event_id]
      Effective::Event.find(attributes[:event_id])
    end
  end

  def event_registration
    @event_registration ||= if attributes[:event_registration_id]
      EffectiveEvents.EventRegistration.find_by_id(attributes[:event_registration_id])
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
effective_events-0.1.7 app/datatables/effective_event_purchases_datatable.rb
effective_events-0.1.6 app/datatables/effective_event_purchases_datatable.rb
effective_events-0.1.5 app/datatables/effective_event_purchases_datatable.rb