Skip to content

Commit

Permalink
Merge branch 'release/1.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalcic committed Oct 11, 2020
2 parents b079c5a + e38be66 commit c20a53b
Show file tree
Hide file tree
Showing 19 changed files with 108 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.0
2.7.1
15 changes: 2 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
spina-admin-conferences (1.0.0)
spina-admin-conferences (1.2.0)
babel-transpiler (~> 0.7)
icalendar (~> 2.5)
mobility (~> 0.8.10)
Expand Down Expand Up @@ -99,7 +99,6 @@ GEM
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.1.7)
connection_pool (2.2.3)
coveralls_reborn (0.18.0)
simplecov (>= 0.18.1, < 0.20.0)
term-ansicolor (~> 1.6)
Expand Down Expand Up @@ -160,7 +159,6 @@ GEM
kaminari-core (= 1.2.1)
kaminari-core (1.2.1)
kwalify (0.7.2)
libv8 (8.4.255.0)
loofah (2.7.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
Expand All @@ -173,8 +171,6 @@ GEM
mini_magick (4.10.1)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
mini_racer (0.3.1)
libv8 (~> 8.4.255)
minitest (5.14.2)
minitest-rails (6.0.1)
minitest (~> 5.10)
Expand Down Expand Up @@ -234,7 +230,6 @@ GEM
thor (>= 0.20.3, < 2.0)
rainbow (3.0.0)
rake (13.0.1)
redis (4.2.2)
reek (6.0.1)
kwalify (~> 0.7.0)
parser (>= 2.5.0.0, < 2.8, != 2.5.1.1)
Expand Down Expand Up @@ -282,10 +277,6 @@ GEM
childprocess (>= 0.5, < 4.0)
rubyzip (>= 1.2.2)
sexp_processor (4.15.1)
sidekiq (6.1.2)
connection_pool (>= 2.2.2)
rack (~> 2.0)
redis (>= 4.2.0)
simplecov (0.19.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
Expand Down Expand Up @@ -352,7 +343,6 @@ DEPENDENCIES
coveralls_reborn
dotenv-rails
image_processing
mini_racer
minitest-rails
minitest-reporters
percy-capybara
Expand All @@ -362,11 +352,10 @@ DEPENDENCIES
rubocop-performance
rubocop-rails
selenium-webdriver
sidekiq
simplecov
spina-admin-conferences!
web-console
webdrivers

BUNDLED WITH
2.1.2
2.1.4
22 changes: 12 additions & 10 deletions app/controllers/spina/admin/conferences/conferences_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ module Conferences
# Controller for {Conference} objects.
# @see Conference
class ConferencesController < ApplicationController
PARTS = [
{ name: 'text', title: 'Text', partable_type: 'Spina::Text' },
{ name: 'submission_url', title: 'Submission URL', partable_type: 'Spina::Admin::Conferences::UrlPart' },
{ name: 'submission_email_address', title: 'Submission email address',
partable_type: 'Spina::Admin::Conferences::EmailAddressPart' },
{ name: 'submission_date', title: 'Submission date', partable_type: 'Spina::Admin::Conferences::DatePart' },
{ name: 'submission_text', title: 'Submission text', partable_type: 'Spina::Line' },
{ name: 'gallery', title: 'Gallery', partable_type: 'Spina::ImageCollection' },
{ name: 'sponsors', title: 'Sponsors', partable_type: 'Spina::Structure' }
].freeze

before_action :set_conference, only: %i[edit update destroy]
before_action :set_conferences_breadcrumb
before_action :set_tabs
Expand Down Expand Up @@ -105,16 +116,7 @@ def set_tabs
end

def set_parts_attributes
@parts_attributes = [
{ name: 'text', title: 'Text', partable_type: 'Spina::Text' },
{ name: 'submission_url', title: 'Submission URL', partable_type: 'Spina::Admin::Conferences::UrlPart' },
{ name: 'submission_email_address', title: 'Submission email address',
partable_type: 'Spina::Admin::Conferences::EmailAddressPart' },
{ name: 'submission_date', title: 'Submission date', partable_type: 'Spina::Admin::Conferences::DatePart' },
{ name: 'submission_text', title: 'Submission text', partable_type: 'Spina::Line' },
{ name: 'gallery', title: 'Gallery', partable_type: 'Spina::ImageCollection' },
{ name: 'sponsors', title: 'Sponsors', partable_type: 'Spina::Structure' }
]
@parts_attributes = PARTS
end

def build_parts
Expand Down
25 changes: 17 additions & 8 deletions app/models/spina/admin/conferences/conference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ module Conferences
class Conference < ApplicationRecord
include Partable

default_scope { includes(:translations) }

# @!attribute [rw] dates
# @return [Range<Date>, nil] the dates of the conference

Expand All @@ -29,37 +31,38 @@ class Conference < ApplicationRecord
# @return [ActiveRecord::Relation] directly associated presentation types
# @note A conference cannot be destroyed if it has dependent presentation types.
# @see PresentationType
has_many :presentation_types, inverse_of: :conference, dependent: :restrict_with_error
has_many :presentation_types, -> { includes(:translations) }, inverse_of: :conference, dependent: :restrict_with_error
# @!attribute [rw] events
# @return [ActiveRecord::Relation] directly associated events
# @note Destroying a conference destroys dependent events.
# @see Event
has_many :events, inverse_of: :conference, dependent: :destroy
has_many :events, -> { includes(:translations) }, inverse_of: :conference, dependent: :destroy
# @!attribute [rw] events
# @return [ActiveRecord::Relation] directly associated events
# @note Destroying a conference destroys dependent events.
# @see Event
has_many :parts, as: :pageable, dependent: :destroy
has_many :parts, -> { includes(:partable) },
as: :pageable, dependent: :destroy
# @!attribute [rw] sessions
# @return [ActiveRecord::Relation] Sessions associated with {#presentation_types}
# @see Session
# @see PresentationType#sessions
has_many :sessions, -> { distinct }, through: :presentation_types
has_many :sessions, -> { distinct.includes(:translations) }, through: :presentation_types
# @!attribute [rw] presentations
# @return [ActiveRecord::Relation] Presentations associated with {#sessions}
# @see Presentation
# @see Session#presentations
has_many :presentations, -> { distinct }, through: :sessions
has_many :presentations, -> { distinct.includes(:translations) }, through: :sessions
# @!attribute [rw] rooms
# @return [ActiveRecord::Relation] Rooms associated with {#sessions}
# @see Room
# @see Session#rooms
has_many :rooms, -> { distinct }, through: :sessions
has_many :rooms, -> { distinct.includes(:translations) }, through: :sessions
# @!attribute [rw] institutions
# @return [ActiveRecord::Relation] Institutions associated with {#rooms}
# @see Institution
# @see Room#institutions
has_many :institutions, -> { distinct }, through: :rooms
has_many :institutions, -> { distinct.includes(:translations) }, through: :rooms
# @!attribute [rw] delegates
# @return [ActiveRecord::Relation] directly associated delegates
# @see Delegate
Expand Down Expand Up @@ -124,7 +127,7 @@ def location
end

# @return [Icalendar::Event] the conference as an iCal event
def to_ics # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
def to_event # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
event = Icalendar::Event.new
return event if invalid?

Expand All @@ -138,6 +141,12 @@ def to_ics # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
event.summary = name
event
end

# @param (see #to_event)
# @deprecated Use {#to_event} instead
def to_ics
to_event
end
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions app/models/spina/admin/conferences/delegate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ class Delegate < ApplicationRecord
# @!attribute [rw] conferences
# @return [ActiveRecord::Relation] directly associated conferences
# @see Conference
has_and_belongs_to_many :conferences, foreign_key: :spina_conferences_delegate_id, # rubocop:disable Rails/HasAndBelongsToMany
has_and_belongs_to_many :conferences, -> { includes(:translations) }, foreign_key: :spina_conferences_delegate_id, # rubocop:disable Rails/HasAndBelongsToMany
association_foreign_key: :spina_conferences_conference_id
# @!attribute [rw] presentations
# @return [ActiveRecord::Relation] directly associated presentations
# @see Presentation
has_and_belongs_to_many :presentations, foreign_key: :spina_conferences_delegate_id, # rubocop:disable Rails/HasAndBelongsToMany
has_and_belongs_to_many :presentations, -> { includes(:translations) }, foreign_key: :spina_conferences_delegate_id, # rubocop:disable Rails/HasAndBelongsToMany
association_foreign_key: :spina_conferences_presentation_id
# @!attribute [rw] dietary_requirements
# @return [ActiveRecord::Relation] directly associated dietary requirements
# @see DietaryRequirement
has_and_belongs_to_many :dietary_requirements, foreign_key: :spina_conferences_delegate_id, # rubocop:disable Rails/HasAndBelongsToMany
has_and_belongs_to_many :dietary_requirements, -> { includes(:translations) }, foreign_key: :spina_conferences_delegate_id, # rubocop:disable Rails/HasAndBelongsToMany
association_foreign_key: :spina_conferences_dietary_requirement_id

validates :first_name, :last_name, presence: true
Expand Down
2 changes: 2 additions & 0 deletions app/models/spina/admin/conferences/dietary_requirement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ module Conferences
# = Translations
# - {#name}
class DietaryRequirement < ApplicationRecord
default_scope { includes(:translations) }

# @!attribute [rw] name
# @return [String, nil] the name of the dietary requirement
translates :name, fallbacks: true
Expand Down
14 changes: 11 additions & 3 deletions app/models/spina/admin/conferences/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ module Conferences
# - {#description}
# - {#location}
class Event < ApplicationRecord
default_scope { includes(:translations) }

# @!attribute [rw] name
# @return [String, nil] the translated name of the conference
# @!attribute [rw] description
Expand All @@ -28,7 +30,7 @@ class Event < ApplicationRecord

# @!attribute [rw] conference
# @return [Conference, nil] directly associated conferences
belongs_to :conference, inverse_of: :events, touch: true
belongs_to :conference, -> { includes(:translations) }, inverse_of: :events, touch: true

validates :name, :date, :start_time, :start_datetime, :finish_time, :finish_datetime, :location, presence: true
validates :date, 'spina/admin/conferences/conference_date': true
Expand Down Expand Up @@ -92,7 +94,7 @@ def finish_time=(finish_time)
end

# @return [Icalendar::Event] the event as an iCal event
def to_ics # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
def to_event # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
event = Icalendar::Event.new
return event if invalid?

Expand All @@ -102,10 +104,16 @@ def to_ics # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
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.append_custom_property('alt_description', description.try(:html_safe))
event.description = description.try(:gsub, %r{</?[^>]*>}, '')
event
end

# @param (see #to_event)
# @deprecated Use {#to_event} instead
def to_ics
to_event
end
end
end
end
Expand Down
4 changes: 3 additions & 1 deletion app/models/spina/admin/conferences/institution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ module Conferences
# - {#name}
# - {#city}
class Institution < ApplicationRecord
default_scope { includes(:translations) }

# @!attribute [rw] name
# @return [String, nil] the name of the institution
# @!attribute [rw] city
Expand All @@ -28,7 +30,7 @@ class Institution < ApplicationRecord
# @return [ActiveRecord::Relation] directly associated rooms
# @note An institution cannot be destroyed if it has dependent rooms.
# @see Room
has_many :rooms, inverse_of: :institution, dependent: :restrict_with_error
has_many :rooms, -> { includes(:translations) }, inverse_of: :institution, dependent: :restrict_with_error
# @!attribute [rw] delegates
# @return [ActiveRecord::Relation] directly associated delegates
# @note This relation accepts nested attributes.
Expand Down
20 changes: 14 additions & 6 deletions app/models/spina/admin/conferences/presentation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ module Conferences
# - {#title}
# - {#abstract}
class Presentation < ApplicationRecord
default_scope { includes(:translations) }

# @!attribute [rw] title
# @return [String, nil] the presentation title
# @!attribute [rw] abstract
Expand All @@ -32,22 +34,22 @@ class Presentation < ApplicationRecord
# @!attribute [rw] session
# @return [Session, nil] directly associated session
# @see Session
belongs_to :session, inverse_of: :presentations, touch: true
belongs_to :session, -> { includes(:translations) }, inverse_of: :presentations, touch: true
# @!attribute [rw] presentation_type
# @return [PresentationType, nil] Presentation type associated with {#session}
# @see PresentationType
# @see Session#presentation_type
has_one :presentation_type, through: :session
has_one :presentation_type, -> { includes(:translations) }, through: :session
# @!attribute [rw] room
# @return [Room, nil] Room associated with {#session}
# @see Session
# @see Session#room
has_one :room, through: :session
has_one :room, -> { includes(:translations) }, through: :session
# @!attribute [rw] conference
# @return [Conference, nil] Conference associated with {#presentation_type}
# @see Conference
# @see PresentationType#conference
has_one :conference, through: :presentation_type
has_one :conference, -> { includes(:translations) }, through: :presentation_type
# @!attribute [rw] attachments
# @return [ActiveRecord::Relation] directly associated presentation attachments
# @note This relation accepts nested attributes.
Expand Down Expand Up @@ -115,7 +117,7 @@ def start_time=(start_time)
end

# @return [Icalendar::Event] the presentation as an iCal event
def to_ics # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
def to_event # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
event = Icalendar::Event.new
return event if invalid?

Expand All @@ -125,10 +127,16 @@ def to_ics # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
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.append_custom_property('alt_description', abstract.try(:html_safe))
event.description = abstract.try(:gsub, %r{</?[^>]*>}, '')
event
end

# @param (see #to_event)
# @deprecated Use {#to_event} instead
def to_ics
to_event
end
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions app/models/spina/admin/conferences/presentation_attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ module Conferences
class PresentationAttachment < ApplicationRecord
# @!attribute [rw] presentation
# @return [Presentation, nil] directly associated presentation
belongs_to :presentation, inverse_of: :attachments, touch: true
belongs_to :presentation, -> { includes(:translations) }, inverse_of: :attachments, touch: true
# @!attribute [rw] presentation_attachment_type
# @return [PresentationAttachmentType, nil] directly associated presentation attachment type
belongs_to :attachment_type, class_name: 'Spina::Admin::Conferences::PresentationAttachmentType',
inverse_of: :presentation_attachments,
touch: true
belongs_to :attachment_type, -> { includes(:translations) }, class_name: 'Spina::Admin::Conferences::PresentationAttachmentType',
inverse_of: :presentation_attachments,
touch: true
# @!attribute [rw] attachment
# @return [Spina::Attachment, nil] directly associated attachment
belongs_to :attachment, class_name: 'Spina::Attachment'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ module Conferences
# = Translations
# - {#name}
class PresentationAttachmentType < ApplicationRecord
default_scope { includes(:translations) }

# @!attribute [rw] name
# @return [String, nil] the name of the presentation attachment type
translates :name, fallbacks: true
Expand Down
Loading

0 comments on commit c20a53b

Please sign in to comment.