Sha256: 6d26f271409a87ed348c10b816839f39f0a82c371204ce09286f9fbd969b1edd

Contents?: true

Size: 1.11 KB

Versions: 5

Compression:

Stored size: 1.11 KB

Contents

# Used on the Event Registrations tickets step

class EffectiveEventRegistrantsDatatable < Effective::Datatable
  datatable do

    col :event_ticket, search: :string, label: 'Ticket'

    col :name do |er|
      "#{er.first_name} #{er.last_name}<br><small>#{mail_to(er.email)}</small>"
    end

    col :first_name, visible: false
    col :last_name, visible: false
    col :email, visible: false
    col :company, visible: false
    col :number, visible: false, label: 'Designations'

    col :price, as: :price
    col :notes

    # no actions_col
  end

  collection do
    scope = Effective::EventRegistrant.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

5 entries across 5 versions & 1 rubygems

Version Path
effective_events-0.2.8 app/datatables/effective_event_registrants_datatable.rb
effective_events-0.2.7 app/datatables/effective_event_registrants_datatable.rb
effective_events-0.2.6 app/datatables/effective_event_registrants_datatable.rb
effective_events-0.2.5 app/datatables/effective_event_registrants_datatable.rb
effective_events-0.2.4 app/datatables/effective_event_registrants_datatable.rb