spina-admin-conferences 1.3.10 → 2.0.0.alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/spina/admin/conferences/application.sass +0 -15
  3. data/app/controllers/spina/admin/conferences/application_controller.rb +6 -3
  4. data/app/controllers/spina/admin/conferences/conferences_controller.rb +18 -27
  5. data/app/controllers/spina/admin/conferences/delegates_controller.rb +2 -4
  6. data/app/controllers/spina/admin/conferences/dietary_requirements_controller.rb +1 -1
  7. data/app/controllers/spina/admin/conferences/institutions_controller.rb +1 -1
  8. data/app/controllers/spina/admin/conferences/presentation_attachment_types_controller.rb +1 -1
  9. data/app/controllers/spina/admin/conferences/presentation_types_controller.rb +1 -1
  10. data/app/controllers/spina/admin/conferences/presentations_controller.rb +4 -5
  11. data/app/controllers/spina/admin/conferences/rooms_controller.rb +1 -1
  12. data/app/controllers/spina/admin/conferences/sessions_controller.rb +1 -1
  13. data/app/jobs/spina/admin/conferences/presentation_import_job.rb +2 -3
  14. data/app/models/spina/admin/conferences/conference.rb +4 -7
  15. data/app/models/spina/admin/conferences/event.rb +21 -58
  16. data/app/models/spina/admin/conferences/presentation.rb +15 -33
  17. data/app/models/spina/parts/admin/conferences/date.rb +14 -0
  18. data/app/models/spina/parts/admin/conferences/email_address.rb +20 -0
  19. data/app/models/spina/parts/admin/conferences/time.rb +14 -0
  20. data/app/models/spina/parts/admin/conferences/url.rb +20 -0
  21. data/app/views/spina/admin/conferences/{delegates/_form_conferences.html.haml → application/_conferences.html.haml} +2 -4
  22. data/app/views/spina/admin/conferences/{conferences/_form_delegates.html.haml → application/_delegates.html.haml} +2 -3
  23. data/app/views/spina/admin/conferences/application/_dietary_requirements.html.haml +9 -0
  24. data/app/views/spina/admin/conferences/application/_institutions.html.haml +10 -0
  25. data/app/views/spina/admin/conferences/application/_presentation_attachment_types.html.haml +10 -0
  26. data/app/views/spina/admin/conferences/{conferences/_form_presentation_types.html.haml → application/_presentation_types.html.haml} +2 -3
  27. data/app/views/spina/admin/conferences/{rooms/_form_presentations.html.haml → application/_presentations.html.haml} +2 -3
  28. data/app/views/spina/admin/conferences/{conferences/_form_rooms.html.haml → application/_rooms.html.haml} +2 -3
  29. data/app/views/spina/admin/conferences/{presentation_types/_form_sessions.html.haml → application/_sessions.html.haml} +2 -3
  30. data/app/views/spina/admin/conferences/conferences/_event_fields.html.haml +15 -21
  31. data/app/views/spina/admin/conferences/conferences/_form.html.haml +7 -3
  32. data/app/views/spina/admin/conferences/conferences/_form_conference_details.html.haml +22 -24
  33. data/app/views/spina/admin/conferences/conferences/_form_parts.html.haml +7 -14
  34. data/app/views/spina/admin/conferences/conferences/index.html.haml +1 -13
  35. data/app/views/spina/admin/conferences/delegates/_form.html.haml +4 -3
  36. data/app/views/spina/admin/conferences/delegates/_form_delegate_details.html.haml +47 -32
  37. data/app/views/spina/admin/conferences/delegates/index.html.haml +1 -12
  38. data/app/views/spina/admin/conferences/dietary_requirements/_form.html.haml +3 -3
  39. data/app/views/spina/admin/conferences/dietary_requirements/_form_dietary_requirement_details.html.haml +7 -8
  40. data/app/views/spina/admin/conferences/dietary_requirements/index.html.haml +1 -10
  41. data/app/views/spina/admin/conferences/institutions/_form.html.haml +4 -3
  42. data/app/views/spina/admin/conferences/institutions/_form_institution_details.html.haml +29 -35
  43. data/app/views/spina/admin/conferences/institutions/index.html.haml +1 -11
  44. data/app/views/spina/admin/conferences/presentation_attachment_types/_form.html.haml +2 -2
  45. data/app/views/spina/admin/conferences/presentation_attachment_types/index.html.haml +1 -10
  46. data/app/views/spina/admin/conferences/presentation_types/_form.html.haml +4 -3
  47. data/app/views/spina/admin/conferences/presentation_types/_form_presentation_type_details.html.haml +13 -17
  48. data/app/views/spina/admin/conferences/presentation_types/index.html.haml +1 -12
  49. data/app/views/spina/admin/conferences/presentations/_attachment_fields.html.haml +6 -15
  50. data/app/views/spina/admin/conferences/presentations/_form.html.haml +3 -3
  51. data/app/views/spina/admin/conferences/presentations/_form_presentation_details.html.haml +56 -55
  52. data/app/views/spina/admin/conferences/presentations/index.html.haml +1 -12
  53. data/app/views/spina/admin/conferences/rooms/_form.html.haml +3 -3
  54. data/app/views/spina/admin/conferences/rooms/_form_room_details.html.haml +13 -15
  55. data/app/views/spina/admin/conferences/rooms/index.html.haml +1 -12
  56. data/app/views/spina/admin/conferences/sessions/_form.html.haml +3 -3
  57. data/app/views/spina/admin/conferences/sessions/_form_session_details.html.haml +18 -20
  58. data/app/views/spina/admin/conferences/sessions/_session.html.haml +1 -1
  59. data/app/views/spina/admin/conferences/sessions/index.html.haml +1 -12
  60. data/app/views/spina/admin/hooks/conferences/_primary_navigation.html.haml +4 -4
  61. data/app/views/spina/admin/hooks/conferences/_settings_secondary_navigation.html.haml +2 -2
  62. data/app/views/spina/admin/parts/admin/conferences/dates/_form.html.haml +2 -0
  63. data/app/views/spina/admin/parts/admin/conferences/email_addresses/_form.html.haml +2 -0
  64. data/app/views/spina/admin/parts/admin/conferences/times/_form.html.haml +2 -0
  65. data/app/views/spina/admin/parts/admin/conferences/urls/_form.html.haml +2 -0
  66. data/config/locales/en.yml +26 -29
  67. data/db/migrate/20210315164409_add_json_attributes_to_spina_conferences_presentations.rb +7 -0
  68. data/db/migrate/20210315164410_add_json_attributes_to_spina_conferences_conferences.rb +7 -0
  69. data/db/migrate/20210315164411_convert_partables_to_json.rb +407 -0
  70. data/lib/spina/admin/conferences/engine.rb +7 -0
  71. data/lib/spina/admin/conferences/version.rb +1 -1
  72. data/lib/tasks/spina/admin/conferences_tasks.rake +11 -1
  73. metadata +27 -31
  74. data/app/helpers/spina/admin/conferences/conferences_helper.rb +0 -44
  75. data/app/models/spina/admin/conferences/date_part.rb +0 -15
  76. data/app/models/spina/admin/conferences/email_address_part.rb +0 -21
  77. data/app/models/spina/admin/conferences/part.rb +0 -20
  78. data/app/models/spina/admin/conferences/time_part.rb +0 -53
  79. data/app/models/spina/admin/conferences/url_part.rb +0 -21
  80. data/app/views/spina/admin/conferences/conferences/_form_presentations.html.haml +0 -12
  81. data/app/views/spina/admin/conferences/delegates/_form_presentations.html.haml +0 -12
  82. data/app/views/spina/admin/conferences/dietary_requirements/_form_delegates.html.haml +0 -12
  83. data/app/views/spina/admin/conferences/institutions/_form_delegates.html.haml +0 -12
  84. data/app/views/spina/admin/conferences/institutions/_form_rooms.html.haml +0 -12
  85. data/app/views/spina/admin/conferences/presentation_types/_form_presentations.html.haml +0 -12
  86. data/app/views/spina/admin/conferences/presentations/_form_presenters.html.haml +0 -12
  87. data/app/views/spina/admin/conferences/sessions/_form_presentations.html.haml +0 -12
  88. data/app/views/spina/admin/partables/admin/conferences/date_parts/_form.html.haml +0 -5
  89. data/app/views/spina/admin/partables/admin/conferences/email_address_parts/_form.html.haml +0 -5
  90. data/app/views/spina/admin/partables/admin/conferences/time_parts/_form.html.haml +0 -7
  91. data/app/views/spina/admin/partables/admin/conferences/url_parts/_form.html.haml +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36fb99cebe29eb7c87ade649d55edb3de239e7f9c6394ffb9f566a3c72102f81
4
- data.tar.gz: 869aa43467a8accd77e2746e7c1f9747bf3cc5fb2915da3388c3f126420d4a7e
3
+ metadata.gz: f2cf050f26e9a9367a69e05ba199802f16edbd573cdc56edf1c2b120e2baf0e6
4
+ data.tar.gz: 6b0288820aef5a159e4f9662dbc1a89e8b9ad627e9788898da8cac4353b193ce
5
5
  SHA512:
6
- metadata.gz: 28095530192cf6a10caf09f4d0e98f7c47354f3d2fe8fc0aae26b65bc8d488bebb76b0b89a0bde1b1867a63180da553e990e8043faa123c78d7e3da5c34258c5
7
- data.tar.gz: 6f5848cde2cbc5023166384ddb6e24fc0ecccf22bdf5d81eba74fb7a516c5b658d6ac8865a400ca8226120723bfdf6b65f6887492e24cc980835207a384608ea
6
+ metadata.gz: 760273d0393107bd95e41dbd2c4dddb94cd971d826afb69bb09aced1775814ebbd354d79254ada1d567a325ab62d50e6b3becfb17e81480b97247407e7231c79
7
+ data.tar.gz: 24cf127eacd47cff18bfd50170b4954c5250a5b2cd89f78af9a46aad69062496a342571beb9b2dd77ab2959d6c81c0c0b72d4e40ad048c4a21b2cb984e6bca3b
@@ -1,18 +1,3 @@
1
- input::-webkit-calendar-picker-indicator
2
- display: none
3
- 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
4
- display: none
5
- input[type="date"]
6
- padding-right: 30px
7
-
8
- .multiple.select-dropdown
9
- z-index: 0
10
- &:before
11
- content: none
12
- select
13
- padding: 11px 10px
14
- width: 100%
15
-
16
1
  .turbo-progress-bar
17
2
  @import spina/configuration
18
3
  background-color: $primary-color
@@ -5,14 +5,17 @@ module Spina
5
5
  module Conferences
6
6
  # @abstract Subclass to implement a custom controller.
7
7
  class ApplicationController < ::Spina::Admin::AdminController
8
+ helper ::Spina::Engine.routes.url_helpers
9
+
8
10
  add_flash_types :success
9
11
 
10
- layout :admin_layout, only: %i[new edit]
12
+ layout 'spina/admin/conferences/application', only: %i[new edit]
13
+ before_action :set_locale
11
14
 
12
15
  private
13
16
 
14
- def admin_layout
15
- 'spina/admin/conferences/application'
17
+ def set_locale
18
+ @locale = params[:locale] || I18n.default_locale
16
19
  end
17
20
  end
18
21
  end
@@ -6,16 +6,21 @@ module Spina
6
6
  # Controller for {Conference} objects.
7
7
  # @see Conference
8
8
  class ConferencesController < ApplicationController
9
- PARTS = [
10
- { name: 'text', title: 'Text', partable_type: 'Spina::Text' },
11
- { name: 'submission_url', title: 'Submission URL', partable_type: 'Spina::Admin::Conferences::UrlPart' },
12
- { name: 'submission_email_address', title: 'Submission email address',
13
- partable_type: 'Spina::Admin::Conferences::EmailAddressPart' },
14
- { name: 'submission_date', title: 'Submission date', partable_type: 'Spina::Admin::Conferences::DatePart' },
15
- { name: 'submission_text', title: 'Submission text', partable_type: 'Spina::Line' },
16
- { name: 'gallery', title: 'Gallery', partable_type: 'Spina::ImageCollection' },
17
- { name: 'sponsors', title: 'Sponsors', partable_type: 'Spina::Structure' }
9
+ PARTS_PARAMS = [
10
+ :name, :title, :type, :content, :filename, :signed_blob_id, :alt, :attachment_id, :image_id,
11
+ images_attributes: %i[filename signed_blob_id image_id alt],
12
+ content_attributes: [
13
+ :name, :title,
14
+ parts_attributes: [
15
+ :name, :title, :type, :content, :filename, :signed_blob_id, :alt, :attachment_id, :image_id,
16
+ images_attributes: %i[filename signed_blob_id image_id alt]
17
+ ]
18
+ ]
18
19
  ].freeze
20
+ CONTENT_PARAMS = Spina.config.locales.inject({}) { |params, locale| params.merge("#{locale}_content_attributes": [*PARTS_PARAMS]) }
21
+ PARAMS = [:start_date, :finish_date, :name, **CONTENT_PARAMS,
22
+ events_attributes: %i[id name start_datetime finish_datetime description location] ].freeze
23
+ PARTS = %w[text submission_url submission_email_address submission_date submission_text gallery sponsors].freeze
19
24
 
20
25
  before_action :set_conference, only: %i[edit update destroy]
21
26
  before_action :set_conferences_breadcrumb
@@ -116,31 +121,17 @@ module Spina
116
121
  end
117
122
 
118
123
  def set_parts_attributes
119
- @parts_attributes = PARTS
124
+ @parts_attributes = current_theme.parts.select { |part| PARTS.include? part[:name] }
120
125
  end
121
126
 
122
127
  def build_parts
123
128
  return unless @parts_attributes.is_a? Array
124
129
 
125
- @conference.parts = @parts_attributes.collect do |part_attributes|
126
- @conference.parts.where(name: part_attributes[:name]).first_or_initialize(**part_attributes)
127
- .tap { |part| part.partable ||= part.partable_type.constantize.new }
128
- end
130
+ @parts = @parts_attributes.collect { |part_attributes| @conference.part(part_attributes) }
129
131
  end
130
132
 
131
- def conference_params # rubocop:disable Metrics/MethodLength
132
- params.require(:admin_conferences_conference).permit(:start_date, :finish_date, :name,
133
- events_attributes:
134
- %i[id name date start_time finish_time description location],
135
- parts_attributes:
136
- [:id, :title, :name, :partable_type, :partable_id,
137
- { partable_attributes:
138
- [:id, :content, :image_tokens, :image_positions, :date, :time,
139
- { structure_items_attributes:
140
- [:id, :position, :_destroy,
141
- { structure_parts_attributes:
142
- [:id, :title, :structure_partable_type, :name, :partable_id,
143
- { partable_attributes: {} }] }] }] }])
133
+ def conference_params
134
+ params.require(:conference).permit(PARAMS)
144
135
  end
145
136
  end
146
137
  end
@@ -105,10 +105,8 @@ module Spina
105
105
  end
106
106
 
107
107
  def delegate_params
108
- params.require(:admin_conferences_delegate).permit(:first_name, :last_name, :email_address, :url,
109
- :institution_id,
110
- conference_ids: [],
111
- dietary_requirement_ids: [])
108
+ params.require(:delegate).permit(:first_name, :last_name, :email_address, :url, :institution_id,
109
+ conference_ids: [], dietary_requirement_ids: [])
112
110
  end
113
111
  end
114
112
  end
@@ -98,7 +98,7 @@ module Spina
98
98
  end
99
99
 
100
100
  def dietary_requirement_params
101
- params.require(:admin_conferences_dietary_requirement).permit(:name)
101
+ params.require(:dietary_requirement).permit(:name)
102
102
  end
103
103
  end
104
104
  end
@@ -98,7 +98,7 @@ module Spina
98
98
  end
99
99
 
100
100
  def conference_params
101
- params.require(:admin_conferences_institution).permit(:name, :city, :logo_id)
101
+ params.require(:institution).permit(:name, :city, :logo_id)
102
102
  end
103
103
  end
104
104
  end
@@ -96,7 +96,7 @@ module Spina
96
96
 
97
97
  # noinspection RubyInstanceMethodNamingConvention
98
98
  def presentation_attachment_type_params
99
- params.require(:admin_conferences_presentation_attachment_type).permit(:name)
99
+ params.require(:presentation_attachment_type).permit(:name)
100
100
  end
101
101
  end
102
102
  end
@@ -101,7 +101,7 @@ module Spina
101
101
  end
102
102
 
103
103
  def presentation_type_params
104
- params.require(:admin_conferences_presentation_type).permit(:name, :conference_id, :minutes)
104
+ params.require(:presentation_type).permit(:name, :conference_id, :minutes)
105
105
  end
106
106
  end
107
107
  end
@@ -98,7 +98,7 @@ module Spina
98
98
  end
99
99
 
100
100
  def set_conferences
101
- @conferences = Conference.all.to_json methods: %i[name localized_dates],
101
+ @conferences = Conference.all.to_json methods: %i[name],
102
102
  include:
103
103
  { presentation_types:
104
104
  { methods: [:name], include: { sessions: { methods: [:name] } } } }
@@ -113,10 +113,9 @@ module Spina
113
113
  end
114
114
 
115
115
  def presentation_params
116
- params.require(:admin_conferences_presentation).permit(:title, :abstract, :session_id, :date, :start_time,
117
- presenter_ids: [],
118
- attachments_attributes:
119
- %i[id attachment_id attachment_type_id _destroy])
116
+ params.require(:presentation).permit(:title, :abstract, :session_id, :start_datetime,
117
+ presenter_ids: [],
118
+ attachments_attributes: %i[id attachment_id attachment_type_id _destroy])
120
119
  end
121
120
  end
122
121
  end
@@ -101,7 +101,7 @@ module Spina
101
101
  end
102
102
 
103
103
  def room_params
104
- params.require(:admin_conferences_room).permit(:building, :number, :institution_id)
104
+ params.require(:room).permit(:building, :number, :institution_id)
105
105
  end
106
106
  end
107
107
  end
@@ -110,7 +110,7 @@ module Spina
110
110
  end
111
111
 
112
112
  def session_params
113
- params.require(:admin_conferences_session).permit(:name, :presentation_type_id, :room_id)
113
+ params.require(:session).permit(:name, :presentation_type_id, :room_id)
114
114
  end
115
115
  end
116
116
  end
@@ -13,8 +13,7 @@ module Spina
13
13
  # == Columns
14
14
  # The CSV should has the following columns. Make sure to include the column names in the header row.
15
15
  # +session_id+:: The id of the associated session.
16
- # +date+:: The date of the presentation, in ISO 8601 format.
17
- # +start_time+:: The start time of the presentation, in HH:MM format.
16
+ # +start_datetime+:: The start time of the presentation, in ISO 8601 format.
18
17
  # +title+:: The title of the presentation for the default locale.
19
18
  # +abstract+:: The presentation's abstract.
20
19
  # +presenter_ids+:: The ids of the presenters.
@@ -30,7 +29,7 @@ module Spina
30
29
 
31
30
  def presentation_params(params)
32
31
  params = ActionController::Parameters.new(params)
33
- params.permit :title, :date, :start_time, :abstract, :session_id, presenter_ids: []
32
+ params.permit :title, :start_datetime, :abstract, :session_id, presenter_ids: []
34
33
  end
35
34
  end
36
35
  end
@@ -13,7 +13,10 @@ module Spina
13
13
  # = Translations
14
14
  # - {#name}
15
15
  class Conference < ApplicationRecord
16
- include Partable
16
+ include AttrJson::Record
17
+ include AttrJson::NestedAttributes
18
+ include Spina::Partable
19
+ include Spina::TranslatedContent
17
20
 
18
21
  default_scope { includes(:translations) }
19
22
 
@@ -37,11 +40,6 @@ module Spina
37
40
  # @note Destroying a conference destroys dependent events.
38
41
  # @see Event
39
42
  has_many :events, -> { includes(:translations) }, inverse_of: :conference, dependent: :destroy
40
- # @!attribute [rw] events
41
- # @return [ActiveRecord::Relation] directly associated events
42
- # @note Destroying a conference destroys dependent events.
43
- # @see Event
44
- has_many :parts, as: :pageable, dependent: :destroy
45
43
  # @!attribute [rw] sessions
46
44
  # @return [ActiveRecord::Relation] Sessions associated with {#presentation_types}
47
45
  # @see Session
@@ -68,7 +66,6 @@ module Spina
68
66
  has_and_belongs_to_many :delegates, foreign_key: :spina_conferences_conference_id, # rubocop:disable Rails/HasAndBelongsToMany
69
67
  association_foreign_key: :spina_conferences_delegate_id
70
68
  accepts_nested_attributes_for :events, allow_destroy: true
71
- accepts_nested_attributes_for :parts, allow_destroy: true
72
69
 
73
70
  validates :name, :start_date, :finish_date, :year, presence: true
74
71
  validates :finish_date, 'spina/admin/conferences/finish_date': true, unless: proc { |conference| conference.start_date.blank? }
@@ -6,8 +6,8 @@ module Spina
6
6
  # Events during conferences.
7
7
  #
8
8
  # = Validators
9
- # Presence:: {#name}, {#start_time}, {#finish_time}.
10
- # Conference date (using {ConferenceDateValidator}):: {#start_time}, {#finish_time}.
9
+ # Presence:: {#name}, {#:start_datetime}, {#:finish_datetime}, {#:location}.
10
+ # Conference date (using {ConferenceDateValidator}):: {#start_datetime}, {#finish_datetime}.
11
11
  # @see ConferenceDateValidator
12
12
  #
13
13
  # = Translations
@@ -18,23 +18,36 @@ module Spina
18
18
  default_scope { includes(:translations) }
19
19
 
20
20
  # @!attribute [rw] name
21
- # @return [String, nil] the translated name of the conference
21
+ # @return [String, nil] the translated name of the event
22
22
  # @!attribute [rw] description
23
- # @return [String, nil] the translated description of the conference
23
+ # @return [String, nil] the translated description of the event
24
+ # @!attribute [rw] start_datetime
25
+ # @return [ActiveSupport::TimeWithZone, nil] the start time of the event
26
+ # @!attribute [rw] finish_datetime
27
+ # @return [ActiveSupport::TimeWithZone, nil] the finish time of the event
24
28
  # @!attribute [rw] location
25
- # @return [String, nil] the translated location of the conference
29
+ # @return [String, nil] the translated location of the event
26
30
  translates :name, :description, :location, fallbacks: true
27
31
 
28
32
  # @return [ActiveRecord::Relation] all events, ordered by name
29
33
  scope :sorted, -> { i18n.order :name }
30
34
 
35
+ # @!attribute [rw] start_time
36
+ # @return [ActiveSupport::TimeWithZone, nil] the start time (alias)
37
+ # @see #start_datetime
38
+ alias_attribute :start_time, :start_datetime
39
+ # @!attribute [rw] :finish_time
40
+ # @return [ActiveSupport::TimeWithZone, nil] the finish time (alias)
41
+ # @see #finish_datetime
42
+ alias_attribute :finish_time, :finish_datetime
43
+
31
44
  # @!attribute [rw] conference
32
45
  # @return [Conference, nil] directly associated conferences
33
46
  belongs_to :conference, -> { includes(:translations) }, inverse_of: :events, touch: true
34
47
 
35
- validates :name, :date, :start_time, :start_datetime, :finish_time, :finish_datetime, :location, presence: true
36
- validates :date, 'spina/admin/conferences/conference_date': true
37
- validates :finish_time, 'spina/admin/conferences/finish_time': true
48
+ validates :name, :start_datetime, :finish_datetime, :location, presence: true
49
+ validates :start_datetime, :finish_datetime, 'spina/admin/conferences/conference_date': true
50
+ validates :finish_datetime, 'spina/admin/conferences/finish_time': true
38
51
 
39
52
  # @return [Date, nil] the start date of the event. Nil if the event has no start date and time
40
53
  def date
@@ -43,56 +56,6 @@ module Spina
43
56
  start_datetime.to_date
44
57
  end
45
58
 
46
- # Sets the date of the presentation.
47
- # @param date [Date] the new date
48
- # @return [void]
49
- def date=(date)
50
- if date.blank? || date.to_date.blank?
51
- self.start_datetime = nil
52
- return
53
- end
54
-
55
- self.start_datetime = date.to_date + (start_datetime.try(:seconds_since_midnight) || 0).seconds
56
- end
57
-
58
- # @return [ActiveSupport::TimeWithZone, nil] the start time of the event. Nil if the event has no start date and time
59
- def start_time
60
- return if start_datetime.blank?
61
-
62
- start_datetime
63
- end
64
-
65
- # Sets the start time of the event.
66
- # @param start_time [ActiveSupport::TimeWithZone] the new start time
67
- # @return [void]
68
- def start_time=(start_time)
69
- if start_time.blank?
70
- self.start_datetime = nil
71
- return
72
- end
73
-
74
- self.start_datetime = Time.parse(start_time, date).to_datetime.in_time_zone
75
- end
76
-
77
- # @return [ActiveSupport::TimeWithZone, nil] the finish time of the event. Nil if the event has no finish date and time
78
- def finish_time
79
- return if finish_datetime.blank?
80
-
81
- finish_datetime
82
- end
83
-
84
- # Sets the finish time of the event.
85
- # @param finish_time [ActiveSupport::TimeWithZone] the new finish time
86
- # @return [void]
87
- def finish_time=(finish_time)
88
- if finish_time.blank?
89
- self.finish_datetime = nil
90
- return
91
- end
92
-
93
- self.finish_datetime = Time.parse(finish_time, date).to_datetime.in_time_zone
94
- end
95
-
96
59
  # @return [Icalendar::Event] the event as an iCal event
97
60
  def to_event # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
98
61
  event = Icalendar::Event.new
@@ -15,6 +15,14 @@ module Spina
15
15
  # - {#title}
16
16
  # - {#abstract}
17
17
  class Presentation < ApplicationRecord
18
+ include AttrJson::Record
19
+ include AttrJson::NestedAttributes
20
+ include Spina::Partable
21
+ include Spina::TranslatedContent
22
+
23
+ # @!attribute [rw] start_datetime
24
+ # @return [ActiveSupport::TimeWithZone, nil] the presentation start time
25
+
18
26
  default_scope { includes(:translations) }
19
27
 
20
28
  # @!attribute [rw] title
@@ -65,11 +73,16 @@ module Spina
65
73
  association_foreign_key: :spina_conferences_delegate_id
66
74
  accepts_nested_attributes_for :attachments, allow_destroy: true
67
75
 
68
- validates :title, :date, :start_time, :start_datetime, :abstract, :presenters, presence: true
69
- validates :date, 'spina/admin/conferences/conference_date': true
76
+ validates :title, :start_datetime, :abstract, :presenters, presence: true
77
+ validates :start_datetime, 'spina/admin/conferences/conference_date': true
70
78
  validates_associated :presenters
71
79
  validates_associated :attachments
72
80
 
81
+ # @!attribute [rw] start_time
82
+ # @return [ActiveSupport::TimeWithZone, nil] the start time (alias)
83
+ # @see #start_datetime
84
+ alias_attribute :start_time, :start_datetime
85
+
73
86
  # Imports a presentation from CSV.
74
87
  # @param file [String] the CSV file to be read
75
88
  # @return [void]
@@ -85,37 +98,6 @@ module Spina
85
98
  start_datetime.to_date
86
99
  end
87
100
 
88
- # Sets the date of the presentation.
89
- # @param date [Date] the new date
90
- # @return [void]
91
- def date=(date)
92
- if date.blank? || date.to_date.blank?
93
- self.start_datetime = nil
94
- return
95
- end
96
-
97
- self.start_datetime = date.to_date + (start_datetime.try(:seconds_since_midnight) || 0).seconds
98
- end
99
-
100
- # @return [ActiveSupport::TimeWithZone, nil] the start time of the presentation. Nil if the presentation has no start date and time
101
- def start_time
102
- return if start_datetime.blank?
103
-
104
- start_datetime
105
- end
106
-
107
- # Sets the start time of the presentation.
108
- # @param start_time [ActiveSupport::TimeWithZone] the new start time
109
- # @return [void]
110
- def start_time=(start_time)
111
- if start_time.blank?
112
- self.start_datetime = nil
113
- return
114
- end
115
-
116
- self.start_datetime = Time.parse(start_time, date).to_datetime.in_time_zone
117
- end
118
-
119
101
  # @return [Icalendar::Event] the presentation as an iCal event
120
102
  def to_event # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
121
103
  event = Icalendar::Event.new