Sha256: a379f0b205a1dc15a616bf18a954d0e4a6b0e4cc7fd3607047560e2b89f32a42

Contents?: true

Size: 1.99 KB

Versions: 7

Compression:

Stored size: 1.99 KB

Contents

# Used on the Event Registrations tickets step

class EffectiveEventRegistrantsDatatable < Effective::Datatable
  datatable do
    order :id

    col :name do |er|
      if er.first_name.present?
        "#{er.first_name} #{er.last_name}<br><small>#{mail_to(er.email)}</small>"
      elsif er.owner.present?
        er.owner.to_s + ' - GUEST'
      else
        'Unknown'
      end
    end

    col :id, visible: false

    col :event_ticket, search: :string, label: 'Ticket' do |er|
      [
        er.event_ticket.to_s,
        (content_tag(:span, 'Waitlist', class: 'badge badge-warning') if er.waitlisted_not_promoted?),
        (content_tag(:span, 'Archived', class: 'badge badge-warning') if er.event_ticket&.archived?)
      ].compact.join('<br>').html_safe
    end

    col :user, label: 'Member', visible: false
    col :first_name, visible: false
    col :last_name, visible: false
    col :email, visible: false
    col :company, visible: false

    col :response1, visible: false
    col :response2, visible: false
    col :response3, visible: false

    col :details do |registrant|
      [registrant.response1.presence, registrant.response2.presence, registrant.response3.presence].compact.map do |response|
        content_tag(:div, response)
      end.join.html_safe
    end

    # This is the non-waitlisted full price
    col :event_ticket_price, as: :price, label: 'Price'
    col :archived, visible: false

    # 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_by_id(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

7 entries across 7 versions & 1 rubygems

Version Path
effective_events-0.17.0 app/datatables/effective_event_registrants_datatable.rb
effective_events-0.16.0 app/datatables/effective_event_registrants_datatable.rb
effective_events-0.15.1 app/datatables/effective_event_registrants_datatable.rb
effective_events-0.15.0 app/datatables/effective_event_registrants_datatable.rb
effective_events-0.14.2 app/datatables/effective_event_registrants_datatable.rb
effective_events-0.14.1 app/datatables/effective_event_registrants_datatable.rb
effective_events-0.14.0 app/datatables/effective_event_registrants_datatable.rb