Skip to content

Commit

Permalink
Merge pull request #339 from jmalcic/dependabot/bundler/spina-2.0.2
Browse files Browse the repository at this point in the history
Update spina requirement from ~> 1.1 to ~> 2.0
  • Loading branch information
jmalcic committed Apr 7, 2021
2 parents 6b7b482 + 02f47b5 commit 9dd02aa
Show file tree
Hide file tree
Showing 152 changed files with 1,784 additions and 1,972 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ AllCops:
Style/CommandLiteral:
EnforcedStyle: mixed

Style/HashAsLastArrayItem:
EnforcedStyle: no_braces

Layout/LineLength:
Max: 140
AutoCorrect: true
Expand Down
17 changes: 10 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ PATH
rails (~> 6.0)
rails-i18n (~> 6.0)
redis (~> 4.2)
spina (~> 1.1)
spina (~> 2.0)
stimulus-rails (~> 0.2.2)
turbo-rails (~> 0.5.9)

Expand Down Expand Up @@ -78,6 +78,8 @@ GEM
activerecord (>= 4.2.0)
ansi (1.5.0)
ast (2.4.2)
attr_json (1.3.0)
activerecord (>= 5.0.0, < 6.2)
bcrypt (3.1.16)
bindex (0.8.1)
breadcrumbs_on_rails (4.0.0)
Expand Down Expand Up @@ -110,7 +112,7 @@ GEM
erubi (1.10.0)
erubis (2.7.0)
execjs (2.7.0)
ffi (1.14.2)
ffi (1.15.0)
globalid (0.4.2)
activesupport (>= 4.2.0)
haml (5.2.1)
Expand All @@ -127,7 +129,7 @@ GEM
haml (>= 4.0, < 6)
nokogiri (>= 1.6.0)
ruby_parser (~> 3.5)
i18n (1.8.9)
i18n (1.8.10)
concurrent-ruby (~> 1.0)
icalendar (2.7.1)
ice_cube (~> 0.16)
Expand Down Expand Up @@ -286,20 +288,21 @@ GEM
simplecov-html (0.12.3)
simplecov-lcov (0.8.0)
simplecov_json_formatter (0.1.2)
spina (1.2.0)
spina (2.0.2)
ancestry
attr_json
bcrypt
breadcrumbs_on_rails
coffee-rails
haml-rails
image_processing
jquery-rails
jsonb_accessor (>= 1.0.0)
kaminari
mini_magick
mobility (>= 0.8.9)
mobility (= 1.1.1)
pg
rack-rewrite (>= 1.5.0)
rails (>= 5.2)
rails (>= 6.0)
sass-rails
turbolinks (~> 5)
sprockets (4.0.2)
Expand Down
15 changes: 0 additions & 15 deletions app/assets/stylesheets/spina/admin/conferences/application.sass
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
input::-webkit-calendar-picker-indicator
display: none
input[type="date"]::-webkit-outer-spin-button, input[type="date"]::-webkit-inner-spin-button, input[type="time"]::-webkit-inner-spin-button, input[type="time"]::-webkit-inner-spin-button
display: none
input[type="date"]
padding-right: 30px

.multiple.select-dropdown
z-index: 0
&:before
content: none
select
padding: 11px 10px
width: 100%

.turbo-progress-bar
@import spina/configuration
background-color: $primary-color
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ module Admin
module Conferences
# @abstract Subclass to implement a custom controller.
class ApplicationController < ::Spina::Admin::AdminController
helper ::Spina::Engine.routes.url_helpers

add_flash_types :success

layout :admin_layout, only: %i[new edit]
layout 'spina/admin/conferences/application', only: %i[new edit]
before_action :set_locale

private

def admin_layout
'spina/admin/conferences/application'
def set_locale
@locale = params[:locale] || I18n.default_locale
end
end
end
Expand Down
45 changes: 18 additions & 27 deletions app/controllers/spina/admin/conferences/conferences_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,21 @@ 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' }
PARTS_PARAMS = [
:name, :title, :type, :content, :filename, :signed_blob_id, :alt, :attachment_id, :image_id,
images_attributes: %i[filename signed_blob_id image_id alt],
content_attributes: [
:name, :title,
parts_attributes: [
:name, :title, :type, :content, :filename, :signed_blob_id, :alt, :attachment_id, :image_id,
images_attributes: %i[filename signed_blob_id image_id alt]
]
]
].freeze
CONTENT_PARAMS = Spina.config.locales.inject({}) { |params, locale| params.merge("#{locale}_content_attributes": [*PARTS_PARAMS]) }
PARAMS = [:start_date, :finish_date, :name, **CONTENT_PARAMS,
events_attributes: %i[id name start_datetime finish_datetime description location] ].freeze
PARTS = %w[text submission_url submission_email_address submission_date submission_text gallery sponsors].freeze

before_action :set_conference, only: %i[edit update destroy]
before_action :set_conferences_breadcrumb
Expand Down Expand Up @@ -116,31 +121,17 @@ def set_tabs
end

def set_parts_attributes
@parts_attributes = PARTS
@parts_attributes = current_theme.parts.select { |part| PARTS.include? part[:name] }
end

def build_parts
return unless @parts_attributes.is_a? Array

@conference.parts = @parts_attributes.collect do |part_attributes|
@conference.parts.where(name: part_attributes[:name]).first_or_initialize(**part_attributes)
.tap { |part| part.partable ||= part.partable_type.constantize.new }
end
@parts = @parts_attributes.collect { |part_attributes| @conference.part(part_attributes) }
end

def conference_params # rubocop:disable Metrics/MethodLength
params.require(:admin_conferences_conference).permit(:start_date, :finish_date, :name,
events_attributes:
%i[id name start_datetime finish_datetime description location],
parts_attributes:
[:id, :title, :name, :partable_type, :partable_id,
{ partable_attributes:
[:id, :content, :image_tokens, :image_positions, :date, :time,
{ structure_items_attributes:
[:id, :position, :_destroy,
{ structure_parts_attributes:
[:id, :title, :structure_partable_type, :name, :partable_id,
{ partable_attributes: {} }] }] }] }])
def conference_params
params.require(:conference).permit(PARAMS)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,8 @@ def set_tabs
end

def delegate_params
params.require(:admin_conferences_delegate).permit(:first_name, :last_name, :email_address, :url,
:institution_id,
conference_ids: [],
dietary_requirement_ids: [])
params.require(:delegate).permit(:first_name, :last_name, :email_address, :url, :institution_id,
conference_ids: [], dietary_requirement_ids: [])
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def set_tabs
end

def dietary_requirement_params
params.require(:admin_conferences_dietary_requirement).permit(:name)
params.require(:dietary_requirement).permit(:name)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def set_tabs
end

def conference_params
params.require(:admin_conferences_institution).permit(:name, :city, :logo_id)
params.require(:institution).permit(:name, :city, :logo_id)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def set_breadcrumb

# noinspection RubyInstanceMethodNamingConvention
def presentation_attachment_type_params
params.require(:admin_conferences_presentation_attachment_type).permit(:name)
params.require(:presentation_attachment_type).permit(:name)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def set_tabs
end

def presentation_type_params
params.require(:admin_conferences_presentation_type).permit(:name, :conference_id, :minutes)
params.require(:presentation_type).permit(:name, :conference_id, :minutes)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,9 @@ def set_tabs
end

def presentation_params
params.require(:admin_conferences_presentation).permit(:title, :abstract, :session_id, :start_datetime,
presenter_ids: [],
attachments_attributes:
%i[id attachment_id attachment_type_id _destroy])
params.require(:presentation).permit(:title, :abstract, :session_id, :start_datetime,
presenter_ids: [],
attachments_attributes: %i[id attachment_id attachment_type_id _destroy])
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def set_tabs
end

def room_params
params.require(:admin_conferences_room).permit(:building, :number, :institution_id)
params.require(:room).permit(:building, :number, :institution_id)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def set_tabs
end

def session_params
params.require(:admin_conferences_session).permit(:name, :presentation_type_id, :room_id)
params.require(:session).permit(:name, :presentation_type_id, :room_id)
end
end
end
Expand Down
44 changes: 0 additions & 44 deletions app/helpers/spina/admin/conferences/conferences_helper.rb

This file was deleted.

11 changes: 4 additions & 7 deletions app/models/spina/admin/conferences/conference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ module Conferences
# = Translations
# - {#name}
class Conference < ApplicationRecord
include Partable
include AttrJson::Record
include AttrJson::NestedAttributes
include Spina::Partable
include Spina::TranslatedContent

default_scope { includes(:translations) }

Expand All @@ -37,11 +40,6 @@ class Conference < ApplicationRecord
# @note Destroying a conference destroys dependent events.
# @see Event
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
# @!attribute [rw] sessions
# @return [ActiveRecord::Relation] Sessions associated with {#presentation_types}
# @see Session
Expand All @@ -68,7 +66,6 @@ class Conference < ApplicationRecord
has_and_belongs_to_many :delegates, foreign_key: :spina_conferences_conference_id, # rubocop:disable Rails/HasAndBelongsToMany
association_foreign_key: :spina_conferences_delegate_id
accepts_nested_attributes_for :events, allow_destroy: true
accepts_nested_attributes_for :parts, allow_destroy: true

validates :name, :start_date, :finish_date, :year, presence: true
validates :finish_date, 'spina/admin/conferences/finish_date': true, unless: proc { |conference| conference.start_date.blank? }
Expand Down
15 changes: 0 additions & 15 deletions app/models/spina/admin/conferences/date_part.rb

This file was deleted.

21 changes: 0 additions & 21 deletions app/models/spina/admin/conferences/email_address_part.rb

This file was deleted.

20 changes: 0 additions & 20 deletions app/models/spina/admin/conferences/part.rb

This file was deleted.

Loading

0 comments on commit 9dd02aa

Please sign in to comment.