Class: Spina::Admin::Conferences::Presentation
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Spina::Admin::Conferences::Presentation
- Includes:
- AttrJson::NestedAttributes, AttrJson::Record, Partable, TranslatedContent
- Defined in:
- app/models/spina/admin/conferences/presentation.rb
Overview
Presentation records.
Validators
- Presence
-
#title, #date, #start_time, #start_datetime, #abstract, #presenters.
- Conference date (using ConferenceDateValidator)
Translations
Instance Attribute Summary collapse
-
#abstract ⇒ String?
The presentation abstract.
-
#attachments ⇒ ActiveRecord::Relation
Directly associated presentation attachments.
-
#conference ⇒ Conference?
Conference associated with #presentation_type.
-
#name ⇒ String?
The presentation title (alias).
-
#presentation_type ⇒ PresentationType?
Presentation type associated with #session.
-
#presenters ⇒ ActiveRecord::Relation
Directly associated delegates.
-
#room ⇒ Room?
Room associated with #session.
-
#session ⇒ Session?
Directly associated session.
-
#start_datetime ⇒ ActiveSupport::TimeWithZone?
The presentation start time.
-
#start_time ⇒ ActiveSupport::TimeWithZone?
The start time (alias).
-
#title ⇒ String?
The presentation title.
Class Method Summary collapse
-
.import(file) ⇒ void
Imports a presentation from CSV.
Instance Method Summary collapse
-
#date ⇒ Date?
The start date of the presentation.
-
#sorted ⇒ ActiveRecord::Relation
All conferences, ordered by date.
-
#to_event ⇒ Icalendar::Event
The presentation as an iCal event.
-
#to_ics ⇒ Object
deprecated
Deprecated.
Use #to_event instead
Instance Attribute Details
#abstract ⇒ String?
Returns the presentation abstract.
32 |
# File 'app/models/spina/admin/conferences/presentation.rb', line 32 translates :title, :abstract, fallbacks: true |
#attachments ⇒ ActiveRecord::Relation
This relation accepts nested attributes.
Destroying a presentation destroys associated attachments.
Returns directly associated presentation attachments.
66 67 |
# File 'app/models/spina/admin/conferences/presentation.rb', line 66 has_many :attachments, class_name: 'Spina::Admin::Conferences::PresentationAttachment', dependent: :destroy, inverse_of: :presentation |
#conference ⇒ Conference?
Returns Conference associated with #presentation_type.
60 |
# File 'app/models/spina/admin/conferences/presentation.rb', line 60 has_one :conference, -> { includes(:translations) }, through: :presentation_type |
#name ⇒ String?
Returns the presentation title (alias).
40 |
# File 'app/models/spina/admin/conferences/presentation.rb', line 40 alias_attribute :name, :title |
#presentation_type ⇒ PresentationType?
Returns Presentation type associated with #session.
50 |
# File 'app/models/spina/admin/conferences/presentation.rb', line 50 has_one :presentation_type, -> { includes(:translations) }, through: :session |
#presenters ⇒ ActiveRecord::Relation
Returns directly associated delegates.
71 72 73 |
# File 'app/models/spina/admin/conferences/presentation.rb', line 71 has_and_belongs_to_many :presenters, class_name: 'Spina::Admin::Conferences::Delegate', # rubocop:disable Rails/HasAndBelongsToMany foreign_key: :spina_conferences_presentation_id, association_foreign_key: :spina_conferences_delegate_id |
#room ⇒ Room?
Returns Room associated with #session.
55 |
# File 'app/models/spina/admin/conferences/presentation.rb', line 55 has_one :room, -> { includes(:translations) }, through: :session |
#session ⇒ Session?
Returns directly associated session.
45 |
# File 'app/models/spina/admin/conferences/presentation.rb', line 45 belongs_to :session, -> { includes(:translations) }, inverse_of: :presentations, touch: true |
#start_datetime ⇒ ActiveSupport::TimeWithZone?
Returns the presentation start time.
26 |
# File 'app/models/spina/admin/conferences/presentation.rb', line 26 default_scope { includes(:translations) } |
#start_time ⇒ ActiveSupport::TimeWithZone?
Returns the start time (alias).
84 |
# File 'app/models/spina/admin/conferences/presentation.rb', line 84 alias_attribute :start_time, :start_datetime |
#title ⇒ String?
Returns the presentation title.
32 |
# File 'app/models/spina/admin/conferences/presentation.rb', line 32 translates :title, :abstract, fallbacks: true |
Class Method Details
.import(file) ⇒ void
This method returns an undefined value.
Imports a presentation from CSV.
90 91 92 |
# File 'app/models/spina/admin/conferences/presentation.rb', line 90 def self.import(file) PresentationImportJob.perform_later IO.read(file) end |
Instance Method Details
#date ⇒ Date?
Returns the start date of the presentation. Nil if the presentation has no start date and time.
95 96 97 98 99 |
# File 'app/models/spina/admin/conferences/presentation.rb', line 95 def date return if start_datetime.blank? start_datetime.to_date end |
#sorted ⇒ ActiveRecord::Relation
Returns all conferences, ordered by date.
35 |
# File 'app/models/spina/admin/conferences/presentation.rb', line 35 scope :sorted, -> { order start_datetime: :desc } |
#to_event ⇒ Icalendar::Event
Returns the presentation as an iCal event.
102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'app/models/spina/admin/conferences/presentation.rb', line 102 def to_event # rubocop:disable Metrics/AbcSize, Metrics/MethodLength event = Icalendar::Event.new return event if invalid? event.dtstart = start_datetime event.dtend = start_datetime + presentation_type.duration event.location = session.room_name presenters.each { |presenter| event.contact = presenter.full_name_and_institution } event.categories = Presentation.model_name.human(count: 0) event.summary = title event.append_custom_property('alt_description', abstract.try(:html_safe)) event.description = abstract.try(:gsub, %r{</?[^>]*>}, '') event end |
#to_ics ⇒ Object
Use #to_event instead
119 120 121 |
# File 'app/models/spina/admin/conferences/presentation.rb', line 119 def to_ics to_event end |