class EventOccurrence

Public Instance Methods

as_indexed_json(*) click to toggle source
# File lib/buweb/event_occurrence.rb, line 43
def as_indexed_json(*)
  {
    event_id: event.id.to_s,
    slug: event.slug,
    title: event.title,
    subtitle: event.subtitle,
    description: event.description,
    page_url: event.page_url,
    start_time: start_time,
    end_time: end_time,
    start_time_index: start_time.to_i,
    end_time_index: (end_time || start_time).to_i,  # in case end_time is nil, use start_time
    all_day: all_day,
    year: start_time.year,
    month: start_time.month,
    day: start_time.day,
    day_span: day_span,
    multiple_day_event: multiple_day_event?,
    organizations: event.departments.to_a.map(&:title) + event.groups.to_a.map(&:title),
    organizations_slugs: event.departments.to_a.map(&:slug) + event.groups.to_a.map(&:slug),
    event_collections_slugs: event.event_collections.to_a.map(&:slug),
    teaser: event.teaser,
    audience: event.audience.to_a.map{|x| x.to_s.downcase.strip.presence }.compact,
    categories: event.site_categories.to_a.map(&:to_s),
    contact_name: event.contact_name,
    contact_email: event.contact_email,
    contact_phone: event.contact_phone,
    admission_info: event.admission_info,
    registration_info: event.registration_info,
    map_url: event.map_url,
    image_medium_url: event.image.medium.url,
    image_small_url: event.image.small.url,
    image_thumb_url: event.image.thumb.url,
    image_url: event.image.url,
    featured: event.featured,
    external_sponsors: event.external_sponsors.to_a.map(&:title),
    location: event.location.to_s
  }
end
day_span() click to toggle source
# File lib/buweb/event_occurrence.rb, line 27
def day_span
  end_time.blank? ? 1 : (end_time.to_date - start_time.to_date + 1).to_i
end
dont_index?() click to toggle source
# File lib/buweb/event_occurrence.rb, line 94
def dont_index?
  !event.published?
end
ends_after_it_starts() click to toggle source
# File lib/buweb/event_occurrence.rb, line 23
def ends_after_it_starts
  errors.add :end_time, 'should be after the start time.' if start_time && end_time && (end_time < start_time)
end
multiple_day_event?() click to toggle source
# File lib/buweb/event_occurrence.rb, line 35
def multiple_day_event?
  day_span > 1
end
projected_ending() click to toggle source
# File lib/buweb/event_occurrence.rb, line 39
def projected_ending
  end_time.blank? ? start_time.end_of_day : end_time
end
single_day_event?() click to toggle source
# File lib/buweb/event_occurrence.rb, line 31
def single_day_event?
  day_span == 1
end