spina-admin-conferences-fork 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +100 -0
- data/Rakefile +40 -0
- data/app/assets/config/spina_admin_conferences_manifest.js +3 -0
- data/app/assets/javascripts/controllers/spina/admin/conferences/conference_events_form_controller.js +174 -0
- data/app/assets/javascripts/controllers/spina/admin/conferences/presentation_attachments_form_controller.js +174 -0
- data/app/assets/javascripts/controllers/spina/admin/conferences/select_options_controller.js +215 -0
- data/app/assets/javascripts/importmap.json.erb +6 -0
- data/app/assets/javascripts/spina/admin/conferences/application.js +4 -0
- data/app/assets/stylesheets/spina/admin/conferences/application.sass +3 -0
- data/app/controllers/spina/admin/conferences/application_controller.rb +23 -0
- data/app/controllers/spina/admin/conferences/conferences_controller.rb +139 -0
- data/app/controllers/spina/admin/conferences/delegates_controller.rb +114 -0
- data/app/controllers/spina/admin/conferences/dietary_requirements_controller.rb +106 -0
- data/app/controllers/spina/admin/conferences/events_controller.rb +24 -0
- data/app/controllers/spina/admin/conferences/institutions_controller.rb +106 -0
- data/app/controllers/spina/admin/conferences/presentation_attachment_types_controller.rb +104 -0
- data/app/controllers/spina/admin/conferences/presentation_attachments_controller.rb +24 -0
- data/app/controllers/spina/admin/conferences/presentation_types_controller.rb +109 -0
- data/app/controllers/spina/admin/conferences/presentations_controller.rb +123 -0
- data/app/controllers/spina/admin/conferences/rooms_controller.rb +109 -0
- data/app/controllers/spina/admin/conferences/sessions_controller.rb +118 -0
- data/app/jobs/spina/admin/conferences/application_job.rb +11 -0
- data/app/jobs/spina/admin/conferences/delegate_import_job.rb +37 -0
- data/app/jobs/spina/admin/conferences/import_job.rb +26 -0
- data/app/jobs/spina/admin/conferences/presentation_import_job.rb +37 -0
- data/app/mailers/spina/admin/conferences/application_mailer.rb +13 -0
- data/app/models/spina/admin/conferences/application_record.rb +14 -0
- data/app/models/spina/admin/conferences/conference.rb +269 -0
- data/app/models/spina/admin/conferences/delegate.rb +89 -0
- data/app/models/spina/admin/conferences/dietary_requirement.rb +33 -0
- data/app/models/spina/admin/conferences/event.rb +85 -0
- data/app/models/spina/admin/conferences/institution.rb +46 -0
- data/app/models/spina/admin/conferences/presentation.rb +134 -0
- data/app/models/spina/admin/conferences/presentation_attachment.rb +27 -0
- data/app/models/spina/admin/conferences/presentation_attachment_type.rb +35 -0
- data/app/models/spina/admin/conferences/presentation_type.rb +60 -0
- data/app/models/spina/admin/conferences/room.rb +52 -0
- data/app/models/spina/admin/conferences/session.rb +56 -0
- data/app/models/spina/admin/conferences.rb +11 -0
- data/app/models/spina/parts/admin/conferences/date.rb +14 -0
- data/app/models/spina/parts/admin/conferences/email_address.rb +20 -0
- data/app/models/spina/parts/admin/conferences/time.rb +14 -0
- data/app/models/spina/parts/admin/conferences/url.rb +20 -0
- data/app/validators/spina/admin/conferences/conference_date_validator.rb +20 -0
- data/app/validators/spina/admin/conferences/email_address_validator.rb +28 -0
- data/app/validators/spina/admin/conferences/finish_date_validator.rb +20 -0
- data/app/validators/spina/admin/conferences/finish_time_validator.rb +20 -0
- data/app/validators/spina/admin/conferences/http_url_validator.rb +28 -0
- data/app/views/layouts/spina/admin/conferences/application.html.haml +6 -0
- data/app/views/layouts/spina/admin/conferences/conferences.html.haml +17 -0
- data/app/views/layouts/spina/admin/conferences/delegates.html.haml +8 -0
- data/app/views/layouts/spina/admin/conferences/dietary_requirements.html.haml +8 -0
- data/app/views/layouts/spina/admin/conferences/institutions.html.haml +15 -0
- data/app/views/layouts/spina/admin/conferences/presentation_attachment_types.html.haml +8 -0
- data/app/views/layouts/spina/admin/conferences/presentations.html.haml +8 -0
- data/app/views/spina/admin/conferences/application/_conferences.html.haml +12 -0
- data/app/views/spina/admin/conferences/application/_delegates.html.haml +11 -0
- data/app/views/spina/admin/conferences/application/_dietary_requirements.html.haml +9 -0
- data/app/views/spina/admin/conferences/application/_empty_list.html.haml +3 -0
- data/app/views/spina/admin/conferences/application/_errors.html.haml +11 -0
- data/app/views/spina/admin/conferences/application/_errors.turbo_stream.haml +1 -0
- data/app/views/spina/admin/conferences/application/_institutions.html.haml +10 -0
- data/app/views/spina/admin/conferences/application/_presentation_attachment_types.html.haml +10 -0
- data/app/views/spina/admin/conferences/application/_presentation_types.html.haml +11 -0
- data/app/views/spina/admin/conferences/application/_presentations.html.haml +11 -0
- data/app/views/spina/admin/conferences/application/_rooms.html.haml +11 -0
- data/app/views/spina/admin/conferences/application/_sessions.html.haml +11 -0
- data/app/views/spina/admin/conferences/conferences/_conference.html.haml +9 -0
- data/app/views/spina/admin/conferences/conferences/_event_fields.html.haml +31 -0
- data/app/views/spina/admin/conferences/conferences/_event_row.html.haml +5 -0
- data/app/views/spina/admin/conferences/conferences/_form.html.haml +27 -0
- data/app/views/spina/admin/conferences/conferences/_form_conference_details.html.haml +27 -0
- data/app/views/spina/admin/conferences/conferences/_form_parts.html.haml +8 -0
- data/app/views/spina/admin/conferences/conferences/_form_structure.html.haml +19 -0
- data/app/views/spina/admin/conferences/conferences/_form_structure_item.html.haml +13 -0
- data/app/views/spina/admin/conferences/conferences/edit.html.haml +1 -0
- data/app/views/spina/admin/conferences/conferences/index.html.haml +7 -0
- data/app/views/spina/admin/conferences/conferences/new.html.haml +1 -0
- data/app/views/spina/admin/conferences/delegates/_delegate.html.haml +13 -0
- data/app/views/spina/admin/conferences/delegates/_form.html.haml +24 -0
- data/app/views/spina/admin/conferences/delegates/_form_delegate_details.html.haml +53 -0
- data/app/views/spina/admin/conferences/delegates/edit.html.haml +1 -0
- data/app/views/spina/admin/conferences/delegates/index.html.haml +13 -0
- data/app/views/spina/admin/conferences/delegates/new.html.haml +1 -0
- data/app/views/spina/admin/conferences/dietary_requirements/_dietary_requirement.html.haml +6 -0
- data/app/views/spina/admin/conferences/dietary_requirements/_form.html.haml +23 -0
- data/app/views/spina/admin/conferences/dietary_requirements/_form_dietary_requirement_details.html.haml +8 -0
- data/app/views/spina/admin/conferences/dietary_requirements/edit.html.haml +1 -0
- data/app/views/spina/admin/conferences/dietary_requirements/index.html.haml +7 -0
- data/app/views/spina/admin/conferences/dietary_requirements/new.html.haml +1 -0
- data/app/views/spina/admin/conferences/events/new.js.erb +21 -0
- data/app/views/spina/admin/conferences/institutions/_form.html.haml +24 -0
- data/app/views/spina/admin/conferences/institutions/_form_institution_details.html.haml +29 -0
- data/app/views/spina/admin/conferences/institutions/_institution.html.haml +7 -0
- data/app/views/spina/admin/conferences/institutions/edit.html.haml +1 -0
- data/app/views/spina/admin/conferences/institutions/index.html.haml +7 -0
- data/app/views/spina/admin/conferences/institutions/new.html.haml +1 -0
- data/app/views/spina/admin/conferences/presentation_attachment_types/_form.html.haml +23 -0
- data/app/views/spina/admin/conferences/presentation_attachment_types/_presentation_attachment_type.html.haml +6 -0
- data/app/views/spina/admin/conferences/presentation_attachment_types/edit.html.haml +1 -0
- data/app/views/spina/admin/conferences/presentation_attachment_types/index.html.haml +7 -0
- data/app/views/spina/admin/conferences/presentation_attachment_types/new.html.haml +1 -0
- data/app/views/spina/admin/conferences/presentation_attachments/new.js.erb +21 -0
- data/app/views/spina/admin/conferences/presentation_types/_form.html.haml +24 -0
- data/app/views/spina/admin/conferences/presentation_types/_form_presentation_type_details.html.haml +16 -0
- data/app/views/spina/admin/conferences/presentation_types/_presentation_type.html.haml +8 -0
- data/app/views/spina/admin/conferences/presentation_types/edit.html.haml +1 -0
- data/app/views/spina/admin/conferences/presentation_types/index.html.haml +7 -0
- data/app/views/spina/admin/conferences/presentation_types/new.html.haml +1 -0
- data/app/views/spina/admin/conferences/presentations/_attachment_fields.html.haml +18 -0
- data/app/views/spina/admin/conferences/presentations/_attachment_row.html.haml +2 -0
- data/app/views/spina/admin/conferences/presentations/_form.html.haml +23 -0
- data/app/views/spina/admin/conferences/presentations/_form_presentation_details.html.haml +55 -0
- data/app/views/spina/admin/conferences/presentations/_presentation.html.haml +11 -0
- data/app/views/spina/admin/conferences/presentations/edit.html.haml +1 -0
- data/app/views/spina/admin/conferences/presentations/index.html.haml +13 -0
- data/app/views/spina/admin/conferences/presentations/new.html.haml +1 -0
- data/app/views/spina/admin/conferences/rooms/_form.html.haml +23 -0
- data/app/views/spina/admin/conferences/rooms/_form_room_details.html.haml +16 -0
- data/app/views/spina/admin/conferences/rooms/_room.html.haml +8 -0
- data/app/views/spina/admin/conferences/rooms/edit.html.haml +1 -0
- data/app/views/spina/admin/conferences/rooms/index.html.haml +7 -0
- data/app/views/spina/admin/conferences/rooms/new.html.haml +1 -0
- data/app/views/spina/admin/conferences/sessions/_form.html.haml +23 -0
- data/app/views/spina/admin/conferences/sessions/_form_session_details.html.haml +21 -0
- data/app/views/spina/admin/conferences/sessions/_session.html.haml +8 -0
- data/app/views/spina/admin/conferences/sessions/edit.html.haml +1 -0
- data/app/views/spina/admin/conferences/sessions/index.html.haml +7 -0
- data/app/views/spina/admin/conferences/sessions/new.html.haml +1 -0
- data/app/views/spina/admin/hooks/conferences/_head.html.haml +7 -0
- data/app/views/spina/admin/hooks/conferences/_primary_navigation.html.haml +21 -0
- data/app/views/spina/admin/hooks/conferences/_settings_secondary_navigation.html.haml +6 -0
- data/app/views/spina/admin/parts/admin/conferences/dates/_form.html.haml +2 -0
- data/app/views/spina/admin/parts/admin/conferences/email_addresses/_form.html.haml +2 -0
- data/app/views/spina/admin/parts/admin/conferences/times/_form.html.haml +2 -0
- data/app/views/spina/admin/parts/admin/conferences/urls/_form.html.haml +2 -0
- data/config/initializers/assets.rb +13 -0
- data/config/locales/en.yml +351 -0
- data/config/routes.rb +27 -0
- data/db/migrate/20180907141228_create_spina_dates.rb +11 -0
- data/db/migrate/20180907141229_create_spina_email_addresses.rb +11 -0
- data/db/migrate/20180907141230_create_spina_urls.rb +11 -0
- data/db/migrate/20180907141231_create_spina_conferences_institutions.rb +12 -0
- data/db/migrate/20180907141232_create_spina_conferences_delegates.rb +15 -0
- data/db/migrate/20180907141234_create_spina_conferences_dietary_requirements.rb +11 -0
- data/db/migrate/20180907141235_create_spina_conferences_conferences.rb +12 -0
- data/db/migrate/20180907141236_create_spina_conferences_presentation_types.rb +13 -0
- data/db/migrate/20180907141238_create_join_table_spina_conferences_conference_delegate.rb +7 -0
- data/db/migrate/20180907141239_create_join_table_spina_conferences_delegate_presentation.rb +7 -0
- data/db/migrate/20180907141240_create_join_table_spina_conferences_delegate_dietary_requirement.rb +7 -0
- data/db/migrate/20180907141242_add_type_to_spina_pages.rb +7 -0
- data/db/migrate/20180907141243_create_spina_conferences_conference_page_parts.rb +14 -0
- data/db/migrate/20180914121905_add_logo_ref_to_spina_conferences_institutions.rb +7 -0
- data/db/migrate/20180916135431_create_spina_conferences_rooms.rb +13 -0
- data/db/migrate/20180916135432_create_spina_conferences_room_possessions.rb +10 -0
- data/db/migrate/20180916135433_create_spina_conferences_room_uses.rb +10 -0
- data/db/migrate/20180916135434_create_spina_conferences_presentations.rb +15 -0
- data/db/migrate/20181009122503_create_spina_times.rb +11 -0
- data/db/migrate/20181009130631_rename_spina_page_parts.rb +10 -0
- data/db/migrate/20181012190811_rename_spina_conferences_page_parts.rb +10 -0
- data/db/migrate/20181012213049_change_start_time_in_spina_conferences_conferences.rb +15 -0
- data/db/migrate/20181012214813_rename_start_time_in_spina_conferences_conferences.rb +7 -0
- data/db/migrate/20181017155705_add_dependent_option_to_foreign_keys.rb +36 -0
- data/db/migrate/20190408131354_change_spina_resources.rb +56 -0
- data/db/migrate/20190622131423_create_spina_conferences_parts.rb +12 -0
- data/db/migrate/20190701174807_remove_spina_conference_pages.rb +199 -0
- data/db/migrate/20190704135524_add_constraints_to_columns.rb +24 -0
- data/db/migrate/20200126034441_create_spina_conferences_presentation_attachment_types.rb +11 -0
- data/db/migrate/20200126213718_create_spina_conferences_presentation_attachments.rb +19 -0
- data/db/migrate/20200420104603_create_spina_conferences_dietary_requirement_name_translations.rb +19 -0
- data/db/migrate/20200420104740_create_spina_conferences_institution_name_and_city_translations.rb +20 -0
- data/db/migrate/20200420105057_create_spina_conferences_presentation_title_and_abstract_translations.rb +20 -0
- data/db/migrate/20200420105144_create_spina_conferences_presentation_attachment_type_name_translations.rb +20 -0
- data/db/migrate/20200420105201_create_spina_conferences_presentation_type_name_translations.rb +19 -0
- data/db/migrate/20200420105458_create_spina_conferences_room_building_and_number_translations.rb +20 -0
- data/db/migrate/20200420110407_move_attributes_to_translation_tables.rb +161 -0
- data/db/migrate/20200420120706_remove_name_from_spina_conferences_dietary_requirements.rb +7 -0
- data/db/migrate/20200420120759_remove_name_and_city_from_spina_conferences_institutions.rb +8 -0
- data/db/migrate/20200420120946_remove_title_and_abstract_from_spina_conferences_presentations.rb +8 -0
- data/db/migrate/20200420121310_remove_name_from_spina_conferences_presentation_attachment_types.rb +7 -0
- data/db/migrate/20200420121321_remove_name_from_spina_conferences_presentation_types.rb +7 -0
- data/db/migrate/20200420121443_remove_building_and_number_from_spina_conferences_rooms.rb +8 -0
- data/db/migrate/20200502133408_create_spina_conferences_conference_name_translations.rb +19 -0
- data/db/migrate/20200502183409_set_name_for_spina_conferences_conferences.rb +47 -0
- data/db/migrate/20200502183410_remove_institution_from_spina_conferences_conferences.rb +8 -0
- data/db/migrate/20200502183719_remove_spina_conferences_room_possessions.rb +60 -0
- data/db/migrate/20200503230732_rename_spina_conferences_room_uses.rb +8 -0
- data/db/migrate/20200510125131_create_spina_conferences_session_name_translations.rb +19 -0
- data/db/migrate/20200802165242_create_spina_conferences_events.rb +13 -0
- data/db/migrate/20200802184921_create_spina_conferences_event_name_description_and_location_translations.rb +21 -0
- data/db/migrate/20200911161632_update_spina_conferences_parts.rb +23 -0
- data/db/migrate/20200911161651_update_spina_parts.rb +37 -0
- data/db/migrate/20200911161726_move_presentation_parts.rb +101 -0
- data/db/migrate/20200911161739_move_conference_parts.rb +221 -0
- data/db/migrate/20201002122517_remove_spina_conferences_conference_page_parts.rb +14 -0
- data/db/migrate/20201007125625_add_timestamps_to_spina_conferences_parts.rb +10 -0
- data/db/migrate/20210315164409_add_json_attributes_to_spina_conferences_presentations.rb +7 -0
- data/db/migrate/20210315164410_add_json_attributes_to_spina_conferences_conferences.rb +7 -0
- data/db/migrate/20210315164411_convert_partables_to_json.rb +407 -0
- data/db/migrate/20210417102513_add_locale_to_action_text_rich_texts.rb +11 -0
- data/db/migrate/20210417102514_move_texts_to_action_text_rich_texts.rb +82 -0
- data/lib/spina/admin/conferences/engine.rb +31 -0
- data/lib/spina/admin/conferences/migration/renaming.rb +79 -0
- data/lib/spina/admin/conferences/railtie.rb +34 -0
- data/lib/spina/admin/conferences/version.rb +10 -0
- data/lib/spina/admin/conferences.rb +23 -0
- data/lib/tasks/spina/admin/conferences_tasks.rake +14 -0
- metadata +603 -0
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Spina
|
4
|
+
module Admin
|
5
|
+
module Conferences
|
6
|
+
# Job for importing {Delegate} objects.
|
7
|
+
# @see Delegate
|
8
|
+
class DelegateImportJob < ImportJob
|
9
|
+
queue_as :default
|
10
|
+
|
11
|
+
# Performs the job.
|
12
|
+
# @param csv [String] the UTF-8-encoded string to parse as a CSV
|
13
|
+
# == Columns
|
14
|
+
# The CSV should has the following columns. Make sure to include the column names in the header row.
|
15
|
+
# +first_name+:: The first name of the delegate.
|
16
|
+
# +last_name+:: The last name of the delegate.
|
17
|
+
# +email_address+:: The email address of the delegate.
|
18
|
+
# +institution_id+:: The id of the current institution of the delegate.
|
19
|
+
# +dietary_requirement_ids+:: The ids of the dietary requirements of the delegate.
|
20
|
+
#
|
21
|
+
# @return [void]
|
22
|
+
def perform(csv)
|
23
|
+
Delegate.transaction do
|
24
|
+
import(csv) { |row| Delegate.create! delegate_params(row.to_h) }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def delegate_params(params)
|
31
|
+
params = ActionController::Parameters.new(params)
|
32
|
+
params.permit :first_name, :last_name, :email_address, :institution_id, conference_ids: [], dietary_requirement_ids: []
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'csv'
|
4
|
+
|
5
|
+
module Spina
|
6
|
+
module Admin
|
7
|
+
module Conferences
|
8
|
+
# Job for importing CSV files.
|
9
|
+
class ImportJob < ApplicationJob
|
10
|
+
CSV::Converters[:json] = lambda do |field|
|
11
|
+
JSON.parse field, symbolize_names: true
|
12
|
+
rescue JSON::ParserError
|
13
|
+
field
|
14
|
+
end
|
15
|
+
|
16
|
+
# Performs the job.
|
17
|
+
# @param file [String] the UTF-8-encoded string to parse as a CSV
|
18
|
+
# @yieldparam row [Hash] the current row of the CSV
|
19
|
+
def import(file)
|
20
|
+
csv_rows = CSV.parse file, encoding: 'UTF-8', headers: true, header_converters: :symbol, converters: [:json]
|
21
|
+
csv_rows.each { |row| yield(row) }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Spina
|
4
|
+
module Admin
|
5
|
+
module Conferences
|
6
|
+
# Job for importing {Presentation} objects
|
7
|
+
# @see Presentation
|
8
|
+
class PresentationImportJob < ImportJob
|
9
|
+
queue_as :default
|
10
|
+
|
11
|
+
# Performs the job.
|
12
|
+
# @param csv [String] the UTF-8-encoded string to parse as a CSV
|
13
|
+
# == Columns
|
14
|
+
# The CSV should has the following columns. Make sure to include the column names in the header row.
|
15
|
+
# +session_id+:: The id of the associated session.
|
16
|
+
# +start_datetime+:: The start time of the presentation, in ISO 8601 format.
|
17
|
+
# +title+:: The title of the presentation for the default locale.
|
18
|
+
# +abstract+:: The presentation's abstract.
|
19
|
+
# +presenter_ids+:: The ids of the presenters.
|
20
|
+
#
|
21
|
+
# @return [void]
|
22
|
+
def perform(csv)
|
23
|
+
Presentation.transaction do
|
24
|
+
import(csv) { |row| Presentation.create! presentation_params(row.to_h) }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def presentation_params(params)
|
31
|
+
params = ActionController::Parameters.new(params)
|
32
|
+
params.permit :title, :start_datetime, :abstract, :session_id, presenter_ids: []
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Spina
|
4
|
+
module Admin
|
5
|
+
module Conferences
|
6
|
+
# @abstract Abstract mailer from which all others inherit.
|
7
|
+
class ApplicationMailer < ActionMailer::Base
|
8
|
+
default from: 'from@example.com'
|
9
|
+
layout 'mailer'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Spina
|
4
|
+
module Admin
|
5
|
+
module Conferences
|
6
|
+
# @abstract Subclass to implement a custom record.
|
7
|
+
class ApplicationRecord < ActiveRecord::Base
|
8
|
+
extend Mobility
|
9
|
+
|
10
|
+
self.abstract_class = true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,269 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Spina
|
4
|
+
module Admin
|
5
|
+
module Conferences
|
6
|
+
# Conference records.
|
7
|
+
#
|
8
|
+
# = Validators
|
9
|
+
# Presence:: {#name}, {#start_date}, {#finish_date}, {#year}.
|
10
|
+
# Conference date (using {FinishDateValidator}):: {#finish_date}.
|
11
|
+
# @see FinishDateValidator
|
12
|
+
#
|
13
|
+
# = Translations
|
14
|
+
# - {#name}
|
15
|
+
class Conference < ApplicationRecord # rubocop:disable Metrics/ClassLength
|
16
|
+
include AttrJson::Record
|
17
|
+
include AttrJson::NestedAttributes
|
18
|
+
include Spina::Partable
|
19
|
+
include Spina::TranslatedContent
|
20
|
+
|
21
|
+
default_scope { includes(:translations) }
|
22
|
+
|
23
|
+
# @!attribute [rw] dates
|
24
|
+
# @return [Range<Date>, nil] the dates of the conference
|
25
|
+
|
26
|
+
# @!attribute [rw] name
|
27
|
+
# @return [String, nil] the translated name of the conference
|
28
|
+
translates :name, fallbacks: true
|
29
|
+
|
30
|
+
# @return [ActiveRecord::Relation] all conferences, ordered by date
|
31
|
+
scope :sorted, -> { order dates: :desc }
|
32
|
+
|
33
|
+
# @!attribute [rw] presentation_types
|
34
|
+
# @return [ActiveRecord::Relation] directly associated presentation types
|
35
|
+
# @note A conference cannot be destroyed if it has dependent presentation types.
|
36
|
+
# @see PresentationType
|
37
|
+
has_many :presentation_types, -> { includes(:translations) }, inverse_of: :conference, dependent: :restrict_with_error
|
38
|
+
# @!attribute [rw] events
|
39
|
+
# @return [ActiveRecord::Relation] directly associated events
|
40
|
+
# @note Destroying a conference destroys dependent events.
|
41
|
+
# @see Event
|
42
|
+
has_many :events, -> { includes(:translations) }, inverse_of: :conference, dependent: :destroy
|
43
|
+
# @!attribute [rw] sessions
|
44
|
+
# @return [ActiveRecord::Relation] Sessions associated with {#presentation_types}
|
45
|
+
# @see Session
|
46
|
+
# @see PresentationType#sessions
|
47
|
+
has_many :sessions, -> { distinct.includes(:translations) }, through: :presentation_types
|
48
|
+
# @!attribute [rw] presentations
|
49
|
+
# @return [ActiveRecord::Relation] Presentations associated with {#sessions}
|
50
|
+
# @see Presentation
|
51
|
+
# @see Session#presentations
|
52
|
+
has_many :presentations, -> { distinct.includes(:translations) }, through: :sessions
|
53
|
+
# @!attribute [rw] rooms
|
54
|
+
# @return [ActiveRecord::Relation] Rooms associated with {#sessions}
|
55
|
+
# @see Room
|
56
|
+
# @see Session#rooms
|
57
|
+
has_many :rooms, -> { distinct.includes(:translations) }, through: :sessions
|
58
|
+
# @!attribute [rw] institutions
|
59
|
+
# @return [ActiveRecord::Relation] Institutions associated with {#rooms}
|
60
|
+
# @see Institution
|
61
|
+
# @see Room#institutions
|
62
|
+
has_many :institutions, -> { distinct.includes(:translations) }, through: :rooms
|
63
|
+
# @!attribute [rw] delegates
|
64
|
+
# @return [ActiveRecord::Relation] directly associated delegates
|
65
|
+
# @see Delegate
|
66
|
+
has_and_belongs_to_many :delegates, foreign_key: :spina_conferences_conference_id, # rubocop:disable Rails/HasAndBelongsToMany
|
67
|
+
association_foreign_key: :spina_conferences_delegate_id
|
68
|
+
accepts_nested_attributes_for :events, allow_destroy: true
|
69
|
+
|
70
|
+
validates :name, :start_date, :finish_date, :year, presence: true
|
71
|
+
validates :finish_date, 'spina/admin/conferences/finish_date': true, unless: proc { |conference| conference.start_date.blank? }
|
72
|
+
|
73
|
+
class << self
|
74
|
+
# @return [Array<TZInfo::TimezonePeriod>] the time zone periods for the conferences
|
75
|
+
def time_zone_periods
|
76
|
+
pluck(:dates).compact.collect(&:begin).collect(&:at_beginning_of_day).collect(&:period)
|
77
|
+
end
|
78
|
+
|
79
|
+
# @return [String] a set of conferences as an iCalendar
|
80
|
+
def to_ics
|
81
|
+
Rails.cache.fetch [all, 'calendar'] do
|
82
|
+
calendar = Icalendar::Calendar.new
|
83
|
+
calendar.x_wr_calname = (Current.account || Spina::Account.first).name
|
84
|
+
calendar.add_timezone(ical_timezone)
|
85
|
+
conference_events.each { |event| calendar.add_event(event) }
|
86
|
+
calendar.publish
|
87
|
+
calendar.to_ical
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
private
|
92
|
+
|
93
|
+
def conference_events
|
94
|
+
Rails.cache.fetch [all, 'events'] do
|
95
|
+
all.in_batches.each_record.collect do |conference|
|
96
|
+
Rails.cache.fetch([conference, 'event']) { conference.to_event }
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def ical_timezone
|
102
|
+
Rails.cache.fetch [self, 'time_zone'] do
|
103
|
+
Icalendar::Timezone.new do |timezone|
|
104
|
+
timezone.tzid = Time.zone.name
|
105
|
+
daylight_periods.each { |daylight_period| timezone.add_daylight(daylight_period) }
|
106
|
+
standard_periods.each { |standard_period| timezone.add_daylight(standard_period) }
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def daylight_periods
|
112
|
+
time_zone_periods.select(&:dst?).each do |period|
|
113
|
+
Icalendar::Timezone::Daylight.new do |ical_period|
|
114
|
+
ical_period.tzoffsetfrom = period.offset.ical_offset
|
115
|
+
ical_period.tzoffsetto = period.offset.ical_offset
|
116
|
+
ical_period.tzname = period.abbreviation
|
117
|
+
ical_period.dtstart = period.starts_at.to_datetime
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def standard_periods
|
123
|
+
time_zone_periods.reject(&:dst?).each do |period|
|
124
|
+
Icalendar::Timezone::Standard.new do |ical_period|
|
125
|
+
ical_period.tzoffsetfrom = period.offset.ical_offset
|
126
|
+
ical_period.tzoffsetto = period.offset.ical_offset
|
127
|
+
ical_period.tzname = period.abbreviation
|
128
|
+
ical_period.dtstart = period.starts_at.to_datetime
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
# @return [Date, nil] the start date of the conference. Nil if the conference has no dates
|
135
|
+
def start_date
|
136
|
+
return if dates.blank?
|
137
|
+
|
138
|
+
dates.begin
|
139
|
+
end
|
140
|
+
|
141
|
+
# Sets the start date of the conference.
|
142
|
+
# @param date [Date] the new start date
|
143
|
+
# @return [void]
|
144
|
+
def start_date=(date)
|
145
|
+
self.dates = date.try(:to_date)..finish_date
|
146
|
+
end
|
147
|
+
|
148
|
+
# @return [Date, nil] the finish date of the conference. Nil if the conference has no dates
|
149
|
+
def finish_date
|
150
|
+
return if dates.blank?
|
151
|
+
|
152
|
+
if dates.exclude_end?
|
153
|
+
dates.end - 1.day if dates.end.is_a? Date
|
154
|
+
else
|
155
|
+
dates.end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
# Sets the finish date of the conference.
|
160
|
+
# @param date [Date] the new finish date
|
161
|
+
# @return [void]
|
162
|
+
def finish_date=(date)
|
163
|
+
self.dates = start_date..date.try(:to_date)
|
164
|
+
end
|
165
|
+
|
166
|
+
# @return [Integer, nil] the year of the conference. Nil if the conference has no dates
|
167
|
+
def year
|
168
|
+
return if start_date.blank?
|
169
|
+
|
170
|
+
start_date.try(:year)
|
171
|
+
end
|
172
|
+
|
173
|
+
# @return [Array<Hash{Symbol=>String}>, nil] an array of hashes containing the date in ISO 8601 format and as a localised string
|
174
|
+
# Nil if the conference has no dates.
|
175
|
+
def localized_dates
|
176
|
+
return if dates.blank?
|
177
|
+
|
178
|
+
dates.entries.collect { |date| { date: date.to_formatted_s(:iso8601), localization: I18n.l(date, format: :long) } }
|
179
|
+
end
|
180
|
+
|
181
|
+
# @return [String] the names of each institution associated with the conference
|
182
|
+
def location
|
183
|
+
institutions.collect(&:name).to_sentence
|
184
|
+
end
|
185
|
+
|
186
|
+
# @return [Icalendar::Event] the conference as an iCal event
|
187
|
+
def to_event # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
188
|
+
event = Icalendar::Event.new
|
189
|
+
return event if invalid?
|
190
|
+
|
191
|
+
event.dtstart = Icalendar::Values::Date.new(dates.begin)
|
192
|
+
event.dtend = Icalendar::Values::Date.new(dates.exclude_end? ? dates.end : dates.end + 1.day)
|
193
|
+
event.location = location
|
194
|
+
event.contact = Spina::Account.first.email
|
195
|
+
event.categories = Conference.model_name.human(count: 0)
|
196
|
+
event.summary = name
|
197
|
+
event
|
198
|
+
end
|
199
|
+
|
200
|
+
# @return [TZInfo::TimezonePeriod, nil] the time zone period for the conference event
|
201
|
+
def time_zone_period
|
202
|
+
return if start_date.blank?
|
203
|
+
|
204
|
+
start_date.at_beginning_of_day.period
|
205
|
+
end
|
206
|
+
|
207
|
+
# @return [String, nil] the conference as an iCalendar
|
208
|
+
def to_ics
|
209
|
+
Rails.cache.fetch [self, presentations, 'calendar'] do
|
210
|
+
calendar = Icalendar::Calendar.new
|
211
|
+
return if invalid?
|
212
|
+
|
213
|
+
calendar.x_wr_calname = name
|
214
|
+
calendar.add_timezone(ical_timezone)
|
215
|
+
eventables_events.each { |event| calendar.add_event(event) }
|
216
|
+
calendar.publish
|
217
|
+
calendar.to_ical
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
private
|
222
|
+
|
223
|
+
def eventables
|
224
|
+
[self, *events, *presentations]
|
225
|
+
end
|
226
|
+
|
227
|
+
def eventables_events
|
228
|
+
Rails.cache.fetch [self, *presentations, 'events'] do
|
229
|
+
eventables.collect do |eventable|
|
230
|
+
Rails.cache.fetch([eventable, 'event']) { eventable.to_event }
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
def ical_timezone
|
236
|
+
Rails.cache.fetch [self, presentations, 'time_zone'] do
|
237
|
+
Icalendar::Timezone.new do |timezone|
|
238
|
+
timezone.tzid = Time.zone.name
|
239
|
+
daylight_periods.each { |daylight_period| timezone.add_daylight(daylight_period) }
|
240
|
+
standard_periods.each { |standard_period| timezone.add_daylight(standard_period) }
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
def daylight_periods
|
246
|
+
time_zone_periods.select(&:dst?).each do |period|
|
247
|
+
Icalendar::Timezone::Daylight.new do |ical_period|
|
248
|
+
ical_period.tzoffsetfrom = period.offset.ical_offset
|
249
|
+
ical_period.tzoffsetto = period.offset.ical_offset
|
250
|
+
ical_period.tzname = period.abbreviation
|
251
|
+
ical_period.dtstart = period.starts_at.to_datetime
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
def standard_periods
|
257
|
+
time_zone_periods.reject(&:dst?).each do |period|
|
258
|
+
Icalendar::Timezone::Standard.new do |ical_period|
|
259
|
+
ical_period.tzoffsetfrom = period.offset.ical_offset
|
260
|
+
ical_period.tzoffsetto = period.offset.ical_offset
|
261
|
+
ical_period.tzname = period.abbreviation
|
262
|
+
ical_period.dtstart = period.starts_at.to_datetime
|
263
|
+
end
|
264
|
+
end
|
265
|
+
end
|
266
|
+
end
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Spina
|
4
|
+
module Admin
|
5
|
+
module Conferences
|
6
|
+
# Delegate records.
|
7
|
+
#
|
8
|
+
# = Validators
|
9
|
+
# Presence:: {#first_name}, {#last_name}.
|
10
|
+
# Email address (using {EmailAddressValidator}):: {#email_address}.
|
11
|
+
# HTTP(S) URL (using {HttpUrlValidator}):: {#url}.
|
12
|
+
# @see EmailAddressValidator
|
13
|
+
# @see HttpUrlValidator
|
14
|
+
class Delegate < ApplicationRecord
|
15
|
+
# @!attribute [rw] first_name
|
16
|
+
# @return [String, nil] the first name of the delegate
|
17
|
+
# @!attribute [rw] last_name
|
18
|
+
# @return [String, nil] the last name of the delegate
|
19
|
+
# @!attribute [rw] email_address
|
20
|
+
# @return [String, nil] the email address of the delegate
|
21
|
+
# @!attribute [rw] url
|
22
|
+
# @return [String, nil] the website belonging to the delegate
|
23
|
+
|
24
|
+
# @return [ActiveRecord::Relation] all delegates, ordered by last name and first name
|
25
|
+
scope :sorted, -> { order :last_name, :first_name }
|
26
|
+
|
27
|
+
# @!attribute [rw] institution
|
28
|
+
# @return [Institution, nil] directly associated institution
|
29
|
+
# @see Institution
|
30
|
+
belongs_to :institution, inverse_of: :delegates, touch: true
|
31
|
+
# @!attribute [rw] conferences
|
32
|
+
# @return [ActiveRecord::Relation] directly associated conferences
|
33
|
+
# @see Conference
|
34
|
+
has_and_belongs_to_many :conferences, -> { includes(:translations) }, foreign_key: :spina_conferences_delegate_id, # rubocop:disable Rails/HasAndBelongsToMany
|
35
|
+
association_foreign_key: :spina_conferences_conference_id
|
36
|
+
# @!attribute [rw] presentations
|
37
|
+
# @return [ActiveRecord::Relation] directly associated presentations
|
38
|
+
# @see Presentation
|
39
|
+
has_and_belongs_to_many :presentations, -> { includes(:translations) }, foreign_key: :spina_conferences_delegate_id, # rubocop:disable Rails/HasAndBelongsToMany
|
40
|
+
association_foreign_key: :spina_conferences_presentation_id
|
41
|
+
# @!attribute [rw] dietary_requirements
|
42
|
+
# @return [ActiveRecord::Relation] directly associated dietary requirements
|
43
|
+
# @see DietaryRequirement
|
44
|
+
has_and_belongs_to_many :dietary_requirements, -> { includes(:translations) }, foreign_key: :spina_conferences_delegate_id, # rubocop:disable Rails/HasAndBelongsToMany
|
45
|
+
association_foreign_key: :spina_conferences_dietary_requirement_id
|
46
|
+
|
47
|
+
validates :first_name, :last_name, presence: true
|
48
|
+
validates :email_address, 'spina/admin/conferences/email_address': true
|
49
|
+
validates :url, 'spina/admin/conferences/http_url': true
|
50
|
+
|
51
|
+
# Imports a conference from CSV.
|
52
|
+
# @param file [String] the CSV file to be read
|
53
|
+
# @return [void]
|
54
|
+
# @see DelegateImportJob
|
55
|
+
def self.import(file)
|
56
|
+
DelegateImportJob.perform_later Pathname.new(file).read
|
57
|
+
end
|
58
|
+
|
59
|
+
# @return [String] the first name and last name of the delegate
|
60
|
+
def full_name
|
61
|
+
return if first_name.blank? || last_name.blank?
|
62
|
+
|
63
|
+
Delegate.human_attribute_name :full_name, first_name: first_name, last_name: last_name
|
64
|
+
end
|
65
|
+
|
66
|
+
# @return [String] the full name and institution of the delegate
|
67
|
+
def full_name_and_institution
|
68
|
+
return if full_name.blank? || institution.blank?
|
69
|
+
|
70
|
+
Delegate.human_attribute_name :name_and_institution, name: full_name, institution: institution.name
|
71
|
+
end
|
72
|
+
|
73
|
+
# @return [String] the last name and first name of the delegate
|
74
|
+
def reversed_name
|
75
|
+
return if first_name.blank? || last_name.blank?
|
76
|
+
|
77
|
+
Delegate.human_attribute_name :reversed_name, first_name: first_name, last_name: last_name
|
78
|
+
end
|
79
|
+
|
80
|
+
# @return [String] the reversed name and institution of the delegate
|
81
|
+
def reversed_name_and_institution
|
82
|
+
return if reversed_name.blank? || institution.blank?
|
83
|
+
|
84
|
+
Delegate.human_attribute_name :name_and_institution, name: reversed_name, institution: institution.name
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Spina
|
4
|
+
module Admin
|
5
|
+
module Conferences
|
6
|
+
# Dietary requirement records.
|
7
|
+
#
|
8
|
+
# = Validators
|
9
|
+
# Presence:: {#name}.
|
10
|
+
#
|
11
|
+
# = Translations
|
12
|
+
# - {#name}
|
13
|
+
class DietaryRequirement < ApplicationRecord
|
14
|
+
default_scope { includes(:translations) }
|
15
|
+
|
16
|
+
# @!attribute [rw] name
|
17
|
+
# @return [String, nil] the name of the dietary requirement
|
18
|
+
translates :name, fallbacks: true
|
19
|
+
|
20
|
+
# @return [ActiveRecord::Relation] all dietary requirements, ordered by name
|
21
|
+
scope :sorted, -> { i18n.order :name }
|
22
|
+
|
23
|
+
# @!attribute [rw] delegates
|
24
|
+
# @return [ActiveRecord::Relation] directly associated delegates
|
25
|
+
# @see Delegate
|
26
|
+
has_and_belongs_to_many :delegates, foreign_key: :spina_conferences_dietary_requirement_id, # rubocop:disable Rails/HasAndBelongsToMany
|
27
|
+
association_foreign_key: :spina_conferences_delegate_id
|
28
|
+
|
29
|
+
validates :name, presence: true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Spina
|
4
|
+
module Admin
|
5
|
+
module Conferences
|
6
|
+
# Events during conferences.
|
7
|
+
#
|
8
|
+
# = Validators
|
9
|
+
# Presence:: {#name}, {#:start_datetime}, {#:finish_datetime}, {#:location}.
|
10
|
+
# Conference date (using {ConferenceDateValidator}):: {#start_datetime}, {#finish_datetime}.
|
11
|
+
# @see ConferenceDateValidator
|
12
|
+
#
|
13
|
+
# = Translations
|
14
|
+
# - {#name}
|
15
|
+
# - {#description}
|
16
|
+
# - {#location}
|
17
|
+
class Event < ApplicationRecord
|
18
|
+
default_scope { includes(:translations) }
|
19
|
+
|
20
|
+
# @!attribute [rw] name
|
21
|
+
# @return [String, nil] the translated name of the event
|
22
|
+
# @!attribute [rw] description
|
23
|
+
# @return [ActionText::RichText, 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
|
28
|
+
# @!attribute [rw] location
|
29
|
+
# @return [String, nil] the translated location of the event
|
30
|
+
translates :name, :location, fallbacks: true
|
31
|
+
translates :description, backend: :action_text, fallbacks: true
|
32
|
+
|
33
|
+
# @return [ActiveRecord::Relation] all events, ordered by name
|
34
|
+
scope :sorted, -> { i18n.order :name }
|
35
|
+
|
36
|
+
# @!attribute [rw] start_time
|
37
|
+
# @return [ActiveSupport::TimeWithZone, nil] the start time (alias)
|
38
|
+
# @see #start_datetime
|
39
|
+
alias_attribute :start_time, :start_datetime
|
40
|
+
# @!attribute [rw] :finish_time
|
41
|
+
# @return [ActiveSupport::TimeWithZone, nil] the finish time (alias)
|
42
|
+
# @see #finish_datetime
|
43
|
+
alias_attribute :finish_time, :finish_datetime
|
44
|
+
|
45
|
+
# @!attribute [rw] conference
|
46
|
+
# @return [Conference, nil] directly associated conferences
|
47
|
+
belongs_to :conference, -> { includes(:translations) }, inverse_of: :events, touch: true
|
48
|
+
|
49
|
+
validates :name, :start_datetime, :finish_datetime, :location, presence: true
|
50
|
+
validates :start_datetime, :finish_datetime, 'spina/admin/conferences/conference_date': true
|
51
|
+
validates :finish_datetime, 'spina/admin/conferences/finish_time': true
|
52
|
+
|
53
|
+
# @return [Date, nil] the start date of the event. Nil if the event has no start date and time
|
54
|
+
def date
|
55
|
+
return if start_datetime.blank?
|
56
|
+
|
57
|
+
start_datetime.to_date
|
58
|
+
end
|
59
|
+
|
60
|
+
# @return [TZInfo::TimezonePeriod, nil] the time zone period for the event
|
61
|
+
def time_zone_period
|
62
|
+
return if start_datetime.blank?
|
63
|
+
|
64
|
+
start_datetime.period
|
65
|
+
end
|
66
|
+
|
67
|
+
# @return [Icalendar::Event] the event as an iCal event
|
68
|
+
def to_event # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
69
|
+
event = Icalendar::Event.new
|
70
|
+
return event if invalid?
|
71
|
+
|
72
|
+
event.dtstart = Icalendar::Values::DateTime.new(start_datetime, tzid: start_datetime.time_zone.tzinfo.name)
|
73
|
+
event.dtend = Icalendar::Values::DateTime.new(finish_datetime, tzid: start_datetime.time_zone.tzinfo.name)
|
74
|
+
event.location = location
|
75
|
+
event.contact = Spina::Account.first.email
|
76
|
+
event.categories = Event.model_name.human(count: 0)
|
77
|
+
event.summary = name
|
78
|
+
event.append_custom_property('alt_description', description.to_s)
|
79
|
+
event.description = description.try(:to_plain_text)
|
80
|
+
event
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Spina
|
4
|
+
module Admin
|
5
|
+
module Conferences
|
6
|
+
# Institution records.
|
7
|
+
#
|
8
|
+
# = Validators
|
9
|
+
# Presence:: {#name}, {#city}.
|
10
|
+
#
|
11
|
+
# = Translations
|
12
|
+
# - {#name}
|
13
|
+
# - {#city}
|
14
|
+
class Institution < ApplicationRecord
|
15
|
+
default_scope { includes(:translations) }
|
16
|
+
|
17
|
+
# @!attribute [rw] name
|
18
|
+
# @return [String, nil] the name of the institution
|
19
|
+
# @!attribute [rw] city
|
20
|
+
# @return [String, nil] the city of the institution
|
21
|
+
translates :name, :city, fallbacks: true
|
22
|
+
|
23
|
+
# @return [ActiveRecord::Relation] all institutions, ordered by name
|
24
|
+
scope :sorted, -> { i18n.order :name }
|
25
|
+
|
26
|
+
# @!attribute [rw] logo
|
27
|
+
# @return [Spina::Image, nil] directly associated image
|
28
|
+
belongs_to :logo, class_name: 'Spina::Image', optional: true
|
29
|
+
# @!attribute [rw] rooms
|
30
|
+
# @return [ActiveRecord::Relation] directly associated rooms
|
31
|
+
# @note An institution cannot be destroyed if it has dependent rooms.
|
32
|
+
# @see Room
|
33
|
+
has_many :rooms, -> { includes(:translations) }, inverse_of: :institution, dependent: :restrict_with_error
|
34
|
+
# @!attribute [rw] delegates
|
35
|
+
# @return [ActiveRecord::Relation] directly associated delegates
|
36
|
+
# @note This relation accepts nested attributes.
|
37
|
+
# @note An institution cannot be destroyed if it has dependent delegates.
|
38
|
+
# @see Delegate
|
39
|
+
has_many :delegates, inverse_of: :institution, dependent: :restrict_with_error
|
40
|
+
accepts_nested_attributes_for :rooms
|
41
|
+
|
42
|
+
validates :name, :city, presence: true
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|