Class: Spina::Admin::Conferences::Event
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Spina::Admin::Conferences::Event
- 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)
Translations
Instance Attribute Summary collapse
-
#:finish_time(: finish_time) ⇒ ActiveSupport::TimeWithZone?
The finish time (alias).
-
#conference ⇒ Conference?
Directly associated conferences.
-
#description ⇒ String?
The translated description of the event.
-
#finish_datetime ⇒ ActiveSupport::TimeWithZone?
The finish time of the event.
-
#location ⇒ String?
The translated location of the event.
-
#name ⇒ String?
The translated name of the event.
-
#start_datetime ⇒ ActiveSupport::TimeWithZone?
The start time of the event.
-
#start_time ⇒ ActiveSupport::TimeWithZone?
The start time (alias).
Instance Method Summary collapse
-
#date ⇒ Date?
The start date of the event.
-
#sorted ⇒ ActiveRecord::Relation
All events, ordered by name.
-
#to_event ⇒ Icalendar::Event
The event as an iCal event.
-
#to_ics ⇒ Object
deprecated
Deprecated.
Use #to_event instead
Instance Attribute Details
#:finish_time(: finish_time) ⇒ ActiveSupport::TimeWithZone?
Returns the finish time (alias).
42 |
# File 'app/models/spina/admin/conferences/event.rb', line 42 alias_attribute :finish_time, :finish_datetime |
#conference ⇒ Conference?
46 |
# File 'app/models/spina/admin/conferences/event.rb', line 46 belongs_to :conference, -> { includes(:translations) }, inverse_of: :events, touch: true |
#description ⇒ String?
30 |
# File 'app/models/spina/admin/conferences/event.rb', line 30 translates :name, :description, :location, fallbacks: true |
#finish_datetime ⇒ ActiveSupport::TimeWithZone?
30 |
# File 'app/models/spina/admin/conferences/event.rb', line 30 translates :name, :description, :location, fallbacks: true |
#location ⇒ String?
30 |
# File 'app/models/spina/admin/conferences/event.rb', line 30 translates :name, :description, :location, fallbacks: true |
#name ⇒ String?
30 |
# File 'app/models/spina/admin/conferences/event.rb', line 30 translates :name, :description, :location, fallbacks: true |
#start_datetime ⇒ ActiveSupport::TimeWithZone?
30 |
# File 'app/models/spina/admin/conferences/event.rb', line 30 translates :name, :description, :location, fallbacks: true |
#start_time ⇒ ActiveSupport::TimeWithZone?
Returns the start time (alias).
38 |
# File 'app/models/spina/admin/conferences/event.rb', line 38 alias_attribute :start_time, :start_datetime |
Instance Method Details
#date ⇒ Date?
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 |
#sorted ⇒ ActiveRecord::Relation
33 |
# File 'app/models/spina/admin/conferences/event.rb', line 33 scope :sorted, -> { i18n.order :name } |
#to_event ⇒ Icalendar::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_ics ⇒ Object
Deprecated.
Use #to_event instead
77 78 79 |
# File 'app/models/spina/admin/conferences/event.rb', line 77 def to_ics to_event end |