Class: Spina::Admin::Conferences::Event

Inherits:
ApplicationRecord show all
Defined in:
app/models/spina/admin/conferences/event.rb

Overview

Events during conferences.

Validators

Presence

#name, #:start_datetime, #:finish_datetime, #:location.

Conference date (using ConferenceDateValidator)

#start_datetime, #finish_datetime.

Translations

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#:finish_time(: finish_time) ⇒ ActiveSupport::TimeWithZone?

Returns the finish time (alias).

See Also:



42
# File 'app/models/spina/admin/conferences/event.rb', line 42

alias_attribute :finish_time, :finish_datetime

#conferenceConference?



46
# File 'app/models/spina/admin/conferences/event.rb', line 46

belongs_to :conference, -> { includes(:translations) }, inverse_of: :events, touch: true

#descriptionString?



30
# File 'app/models/spina/admin/conferences/event.rb', line 30

translates :name, :description, :location, fallbacks: true

#finish_datetimeActiveSupport::TimeWithZone?



30
# File 'app/models/spina/admin/conferences/event.rb', line 30

translates :name, :description, :location, fallbacks: true

#locationString?



30
# File 'app/models/spina/admin/conferences/event.rb', line 30

translates :name, :description, :location, fallbacks: true

#nameString?



30
# File 'app/models/spina/admin/conferences/event.rb', line 30

translates :name, :description, :location, fallbacks: true

#start_datetimeActiveSupport::TimeWithZone?



30
# File 'app/models/spina/admin/conferences/event.rb', line 30

translates :name, :description, :location, fallbacks: true

#start_timeActiveSupport::TimeWithZone?

Returns the start time (alias).

See Also:



38
# File 'app/models/spina/admin/conferences/event.rb', line 38

alias_attribute :start_time, :start_datetime

Instance Method Details

#dateDate?



53
54
55
56
57
# File 'app/models/spina/admin/conferences/event.rb', line 53

def date
  return if start_datetime.blank?

  start_datetime.to_date
end

#sortedActiveRecord::Relation



33
# File 'app/models/spina/admin/conferences/event.rb', line 33

scope :sorted, -> { i18n.order :name }

#to_eventIcalendar::Event



60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'app/models/spina/admin/conferences/event.rb', line 60

def to_event # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
  event = Icalendar::Event.new
  return event if invalid?

  event.dtstart = start_datetime
  event.dtend = finish_datetime
  event.location = location
  event.contact = Spina::Account.first.email
  event.categories = Event.model_name.human(count: 0)
  event.summary = name
  event.append_custom_property('alt_description', description.try(:html_safe))
  event.description = description.try(:gsub, %r{</?[^>]*>}, '')
  event
end

#to_icsObject

Deprecated.

Use #to_event instead



77
78
79
# File 'app/models/spina/admin/conferences/event.rb', line 77

def to_ics
  to_event
end