spina-admin-conferences-fork 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (210) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +100 -0
  4. data/Rakefile +40 -0
  5. data/app/assets/config/spina_admin_conferences_manifest.js +3 -0
  6. data/app/assets/javascripts/controllers/spina/admin/conferences/conference_events_form_controller.js +174 -0
  7. data/app/assets/javascripts/controllers/spina/admin/conferences/presentation_attachments_form_controller.js +174 -0
  8. data/app/assets/javascripts/controllers/spina/admin/conferences/select_options_controller.js +215 -0
  9. data/app/assets/javascripts/importmap.json.erb +6 -0
  10. data/app/assets/javascripts/spina/admin/conferences/application.js +4 -0
  11. data/app/assets/stylesheets/spina/admin/conferences/application.sass +3 -0
  12. data/app/controllers/spina/admin/conferences/application_controller.rb +23 -0
  13. data/app/controllers/spina/admin/conferences/conferences_controller.rb +139 -0
  14. data/app/controllers/spina/admin/conferences/delegates_controller.rb +114 -0
  15. data/app/controllers/spina/admin/conferences/dietary_requirements_controller.rb +106 -0
  16. data/app/controllers/spina/admin/conferences/events_controller.rb +24 -0
  17. data/app/controllers/spina/admin/conferences/institutions_controller.rb +106 -0
  18. data/app/controllers/spina/admin/conferences/presentation_attachment_types_controller.rb +104 -0
  19. data/app/controllers/spina/admin/conferences/presentation_attachments_controller.rb +24 -0
  20. data/app/controllers/spina/admin/conferences/presentation_types_controller.rb +109 -0
  21. data/app/controllers/spina/admin/conferences/presentations_controller.rb +123 -0
  22. data/app/controllers/spina/admin/conferences/rooms_controller.rb +109 -0
  23. data/app/controllers/spina/admin/conferences/sessions_controller.rb +118 -0
  24. data/app/jobs/spina/admin/conferences/application_job.rb +11 -0
  25. data/app/jobs/spina/admin/conferences/delegate_import_job.rb +37 -0
  26. data/app/jobs/spina/admin/conferences/import_job.rb +26 -0
  27. data/app/jobs/spina/admin/conferences/presentation_import_job.rb +37 -0
  28. data/app/mailers/spina/admin/conferences/application_mailer.rb +13 -0
  29. data/app/models/spina/admin/conferences/application_record.rb +14 -0
  30. data/app/models/spina/admin/conferences/conference.rb +269 -0
  31. data/app/models/spina/admin/conferences/delegate.rb +89 -0
  32. data/app/models/spina/admin/conferences/dietary_requirement.rb +33 -0
  33. data/app/models/spina/admin/conferences/event.rb +85 -0
  34. data/app/models/spina/admin/conferences/institution.rb +46 -0
  35. data/app/models/spina/admin/conferences/presentation.rb +134 -0
  36. data/app/models/spina/admin/conferences/presentation_attachment.rb +27 -0
  37. data/app/models/spina/admin/conferences/presentation_attachment_type.rb +35 -0
  38. data/app/models/spina/admin/conferences/presentation_type.rb +60 -0
  39. data/app/models/spina/admin/conferences/room.rb +52 -0
  40. data/app/models/spina/admin/conferences/session.rb +56 -0
  41. data/app/models/spina/admin/conferences.rb +11 -0
  42. data/app/models/spina/parts/admin/conferences/date.rb +14 -0
  43. data/app/models/spina/parts/admin/conferences/email_address.rb +20 -0
  44. data/app/models/spina/parts/admin/conferences/time.rb +14 -0
  45. data/app/models/spina/parts/admin/conferences/url.rb +20 -0
  46. data/app/validators/spina/admin/conferences/conference_date_validator.rb +20 -0
  47. data/app/validators/spina/admin/conferences/email_address_validator.rb +28 -0
  48. data/app/validators/spina/admin/conferences/finish_date_validator.rb +20 -0
  49. data/app/validators/spina/admin/conferences/finish_time_validator.rb +20 -0
  50. data/app/validators/spina/admin/conferences/http_url_validator.rb +28 -0
  51. data/app/views/layouts/spina/admin/conferences/application.html.haml +6 -0
  52. data/app/views/layouts/spina/admin/conferences/conferences.html.haml +17 -0
  53. data/app/views/layouts/spina/admin/conferences/delegates.html.haml +8 -0
  54. data/app/views/layouts/spina/admin/conferences/dietary_requirements.html.haml +8 -0
  55. data/app/views/layouts/spina/admin/conferences/institutions.html.haml +15 -0
  56. data/app/views/layouts/spina/admin/conferences/presentation_attachment_types.html.haml +8 -0
  57. data/app/views/layouts/spina/admin/conferences/presentations.html.haml +8 -0
  58. data/app/views/spina/admin/conferences/application/_conferences.html.haml +12 -0
  59. data/app/views/spina/admin/conferences/application/_delegates.html.haml +11 -0
  60. data/app/views/spina/admin/conferences/application/_dietary_requirements.html.haml +9 -0
  61. data/app/views/spina/admin/conferences/application/_empty_list.html.haml +3 -0
  62. data/app/views/spina/admin/conferences/application/_errors.html.haml +11 -0
  63. data/app/views/spina/admin/conferences/application/_errors.turbo_stream.haml +1 -0
  64. data/app/views/spina/admin/conferences/application/_institutions.html.haml +10 -0
  65. data/app/views/spina/admin/conferences/application/_presentation_attachment_types.html.haml +10 -0
  66. data/app/views/spina/admin/conferences/application/_presentation_types.html.haml +11 -0
  67. data/app/views/spina/admin/conferences/application/_presentations.html.haml +11 -0
  68. data/app/views/spina/admin/conferences/application/_rooms.html.haml +11 -0
  69. data/app/views/spina/admin/conferences/application/_sessions.html.haml +11 -0
  70. data/app/views/spina/admin/conferences/conferences/_conference.html.haml +9 -0
  71. data/app/views/spina/admin/conferences/conferences/_event_fields.html.haml +31 -0
  72. data/app/views/spina/admin/conferences/conferences/_event_row.html.haml +5 -0
  73. data/app/views/spina/admin/conferences/conferences/_form.html.haml +27 -0
  74. data/app/views/spina/admin/conferences/conferences/_form_conference_details.html.haml +27 -0
  75. data/app/views/spina/admin/conferences/conferences/_form_parts.html.haml +8 -0
  76. data/app/views/spina/admin/conferences/conferences/_form_structure.html.haml +19 -0
  77. data/app/views/spina/admin/conferences/conferences/_form_structure_item.html.haml +13 -0
  78. data/app/views/spina/admin/conferences/conferences/edit.html.haml +1 -0
  79. data/app/views/spina/admin/conferences/conferences/index.html.haml +7 -0
  80. data/app/views/spina/admin/conferences/conferences/new.html.haml +1 -0
  81. data/app/views/spina/admin/conferences/delegates/_delegate.html.haml +13 -0
  82. data/app/views/spina/admin/conferences/delegates/_form.html.haml +24 -0
  83. data/app/views/spina/admin/conferences/delegates/_form_delegate_details.html.haml +53 -0
  84. data/app/views/spina/admin/conferences/delegates/edit.html.haml +1 -0
  85. data/app/views/spina/admin/conferences/delegates/index.html.haml +13 -0
  86. data/app/views/spina/admin/conferences/delegates/new.html.haml +1 -0
  87. data/app/views/spina/admin/conferences/dietary_requirements/_dietary_requirement.html.haml +6 -0
  88. data/app/views/spina/admin/conferences/dietary_requirements/_form.html.haml +23 -0
  89. data/app/views/spina/admin/conferences/dietary_requirements/_form_dietary_requirement_details.html.haml +8 -0
  90. data/app/views/spina/admin/conferences/dietary_requirements/edit.html.haml +1 -0
  91. data/app/views/spina/admin/conferences/dietary_requirements/index.html.haml +7 -0
  92. data/app/views/spina/admin/conferences/dietary_requirements/new.html.haml +1 -0
  93. data/app/views/spina/admin/conferences/events/new.js.erb +21 -0
  94. data/app/views/spina/admin/conferences/institutions/_form.html.haml +24 -0
  95. data/app/views/spina/admin/conferences/institutions/_form_institution_details.html.haml +29 -0
  96. data/app/views/spina/admin/conferences/institutions/_institution.html.haml +7 -0
  97. data/app/views/spina/admin/conferences/institutions/edit.html.haml +1 -0
  98. data/app/views/spina/admin/conferences/institutions/index.html.haml +7 -0
  99. data/app/views/spina/admin/conferences/institutions/new.html.haml +1 -0
  100. data/app/views/spina/admin/conferences/presentation_attachment_types/_form.html.haml +23 -0
  101. data/app/views/spina/admin/conferences/presentation_attachment_types/_presentation_attachment_type.html.haml +6 -0
  102. data/app/views/spina/admin/conferences/presentation_attachment_types/edit.html.haml +1 -0
  103. data/app/views/spina/admin/conferences/presentation_attachment_types/index.html.haml +7 -0
  104. data/app/views/spina/admin/conferences/presentation_attachment_types/new.html.haml +1 -0
  105. data/app/views/spina/admin/conferences/presentation_attachments/new.js.erb +21 -0
  106. data/app/views/spina/admin/conferences/presentation_types/_form.html.haml +24 -0
  107. data/app/views/spina/admin/conferences/presentation_types/_form_presentation_type_details.html.haml +16 -0
  108. data/app/views/spina/admin/conferences/presentation_types/_presentation_type.html.haml +8 -0
  109. data/app/views/spina/admin/conferences/presentation_types/edit.html.haml +1 -0
  110. data/app/views/spina/admin/conferences/presentation_types/index.html.haml +7 -0
  111. data/app/views/spina/admin/conferences/presentation_types/new.html.haml +1 -0
  112. data/app/views/spina/admin/conferences/presentations/_attachment_fields.html.haml +18 -0
  113. data/app/views/spina/admin/conferences/presentations/_attachment_row.html.haml +2 -0
  114. data/app/views/spina/admin/conferences/presentations/_form.html.haml +23 -0
  115. data/app/views/spina/admin/conferences/presentations/_form_presentation_details.html.haml +55 -0
  116. data/app/views/spina/admin/conferences/presentations/_presentation.html.haml +11 -0
  117. data/app/views/spina/admin/conferences/presentations/edit.html.haml +1 -0
  118. data/app/views/spina/admin/conferences/presentations/index.html.haml +13 -0
  119. data/app/views/spina/admin/conferences/presentations/new.html.haml +1 -0
  120. data/app/views/spina/admin/conferences/rooms/_form.html.haml +23 -0
  121. data/app/views/spina/admin/conferences/rooms/_form_room_details.html.haml +16 -0
  122. data/app/views/spina/admin/conferences/rooms/_room.html.haml +8 -0
  123. data/app/views/spina/admin/conferences/rooms/edit.html.haml +1 -0
  124. data/app/views/spina/admin/conferences/rooms/index.html.haml +7 -0
  125. data/app/views/spina/admin/conferences/rooms/new.html.haml +1 -0
  126. data/app/views/spina/admin/conferences/sessions/_form.html.haml +23 -0
  127. data/app/views/spina/admin/conferences/sessions/_form_session_details.html.haml +21 -0
  128. data/app/views/spina/admin/conferences/sessions/_session.html.haml +8 -0
  129. data/app/views/spina/admin/conferences/sessions/edit.html.haml +1 -0
  130. data/app/views/spina/admin/conferences/sessions/index.html.haml +7 -0
  131. data/app/views/spina/admin/conferences/sessions/new.html.haml +1 -0
  132. data/app/views/spina/admin/hooks/conferences/_head.html.haml +7 -0
  133. data/app/views/spina/admin/hooks/conferences/_primary_navigation.html.haml +21 -0
  134. data/app/views/spina/admin/hooks/conferences/_settings_secondary_navigation.html.haml +6 -0
  135. data/app/views/spina/admin/parts/admin/conferences/dates/_form.html.haml +2 -0
  136. data/app/views/spina/admin/parts/admin/conferences/email_addresses/_form.html.haml +2 -0
  137. data/app/views/spina/admin/parts/admin/conferences/times/_form.html.haml +2 -0
  138. data/app/views/spina/admin/parts/admin/conferences/urls/_form.html.haml +2 -0
  139. data/config/initializers/assets.rb +13 -0
  140. data/config/locales/en.yml +351 -0
  141. data/config/routes.rb +27 -0
  142. data/db/migrate/20180907141228_create_spina_dates.rb +11 -0
  143. data/db/migrate/20180907141229_create_spina_email_addresses.rb +11 -0
  144. data/db/migrate/20180907141230_create_spina_urls.rb +11 -0
  145. data/db/migrate/20180907141231_create_spina_conferences_institutions.rb +12 -0
  146. data/db/migrate/20180907141232_create_spina_conferences_delegates.rb +15 -0
  147. data/db/migrate/20180907141234_create_spina_conferences_dietary_requirements.rb +11 -0
  148. data/db/migrate/20180907141235_create_spina_conferences_conferences.rb +12 -0
  149. data/db/migrate/20180907141236_create_spina_conferences_presentation_types.rb +13 -0
  150. data/db/migrate/20180907141238_create_join_table_spina_conferences_conference_delegate.rb +7 -0
  151. data/db/migrate/20180907141239_create_join_table_spina_conferences_delegate_presentation.rb +7 -0
  152. data/db/migrate/20180907141240_create_join_table_spina_conferences_delegate_dietary_requirement.rb +7 -0
  153. data/db/migrate/20180907141242_add_type_to_spina_pages.rb +7 -0
  154. data/db/migrate/20180907141243_create_spina_conferences_conference_page_parts.rb +14 -0
  155. data/db/migrate/20180914121905_add_logo_ref_to_spina_conferences_institutions.rb +7 -0
  156. data/db/migrate/20180916135431_create_spina_conferences_rooms.rb +13 -0
  157. data/db/migrate/20180916135432_create_spina_conferences_room_possessions.rb +10 -0
  158. data/db/migrate/20180916135433_create_spina_conferences_room_uses.rb +10 -0
  159. data/db/migrate/20180916135434_create_spina_conferences_presentations.rb +15 -0
  160. data/db/migrate/20181009122503_create_spina_times.rb +11 -0
  161. data/db/migrate/20181009130631_rename_spina_page_parts.rb +10 -0
  162. data/db/migrate/20181012190811_rename_spina_conferences_page_parts.rb +10 -0
  163. data/db/migrate/20181012213049_change_start_time_in_spina_conferences_conferences.rb +15 -0
  164. data/db/migrate/20181012214813_rename_start_time_in_spina_conferences_conferences.rb +7 -0
  165. data/db/migrate/20181017155705_add_dependent_option_to_foreign_keys.rb +36 -0
  166. data/db/migrate/20190408131354_change_spina_resources.rb +56 -0
  167. data/db/migrate/20190622131423_create_spina_conferences_parts.rb +12 -0
  168. data/db/migrate/20190701174807_remove_spina_conference_pages.rb +199 -0
  169. data/db/migrate/20190704135524_add_constraints_to_columns.rb +24 -0
  170. data/db/migrate/20200126034441_create_spina_conferences_presentation_attachment_types.rb +11 -0
  171. data/db/migrate/20200126213718_create_spina_conferences_presentation_attachments.rb +19 -0
  172. data/db/migrate/20200420104603_create_spina_conferences_dietary_requirement_name_translations.rb +19 -0
  173. data/db/migrate/20200420104740_create_spina_conferences_institution_name_and_city_translations.rb +20 -0
  174. data/db/migrate/20200420105057_create_spina_conferences_presentation_title_and_abstract_translations.rb +20 -0
  175. data/db/migrate/20200420105144_create_spina_conferences_presentation_attachment_type_name_translations.rb +20 -0
  176. data/db/migrate/20200420105201_create_spina_conferences_presentation_type_name_translations.rb +19 -0
  177. data/db/migrate/20200420105458_create_spina_conferences_room_building_and_number_translations.rb +20 -0
  178. data/db/migrate/20200420110407_move_attributes_to_translation_tables.rb +161 -0
  179. data/db/migrate/20200420120706_remove_name_from_spina_conferences_dietary_requirements.rb +7 -0
  180. data/db/migrate/20200420120759_remove_name_and_city_from_spina_conferences_institutions.rb +8 -0
  181. data/db/migrate/20200420120946_remove_title_and_abstract_from_spina_conferences_presentations.rb +8 -0
  182. data/db/migrate/20200420121310_remove_name_from_spina_conferences_presentation_attachment_types.rb +7 -0
  183. data/db/migrate/20200420121321_remove_name_from_spina_conferences_presentation_types.rb +7 -0
  184. data/db/migrate/20200420121443_remove_building_and_number_from_spina_conferences_rooms.rb +8 -0
  185. data/db/migrate/20200502133408_create_spina_conferences_conference_name_translations.rb +19 -0
  186. data/db/migrate/20200502183409_set_name_for_spina_conferences_conferences.rb +47 -0
  187. data/db/migrate/20200502183410_remove_institution_from_spina_conferences_conferences.rb +8 -0
  188. data/db/migrate/20200502183719_remove_spina_conferences_room_possessions.rb +60 -0
  189. data/db/migrate/20200503230732_rename_spina_conferences_room_uses.rb +8 -0
  190. data/db/migrate/20200510125131_create_spina_conferences_session_name_translations.rb +19 -0
  191. data/db/migrate/20200802165242_create_spina_conferences_events.rb +13 -0
  192. data/db/migrate/20200802184921_create_spina_conferences_event_name_description_and_location_translations.rb +21 -0
  193. data/db/migrate/20200911161632_update_spina_conferences_parts.rb +23 -0
  194. data/db/migrate/20200911161651_update_spina_parts.rb +37 -0
  195. data/db/migrate/20200911161726_move_presentation_parts.rb +101 -0
  196. data/db/migrate/20200911161739_move_conference_parts.rb +221 -0
  197. data/db/migrate/20201002122517_remove_spina_conferences_conference_page_parts.rb +14 -0
  198. data/db/migrate/20201007125625_add_timestamps_to_spina_conferences_parts.rb +10 -0
  199. data/db/migrate/20210315164409_add_json_attributes_to_spina_conferences_presentations.rb +7 -0
  200. data/db/migrate/20210315164410_add_json_attributes_to_spina_conferences_conferences.rb +7 -0
  201. data/db/migrate/20210315164411_convert_partables_to_json.rb +407 -0
  202. data/db/migrate/20210417102513_add_locale_to_action_text_rich_texts.rb +11 -0
  203. data/db/migrate/20210417102514_move_texts_to_action_text_rich_texts.rb +82 -0
  204. data/lib/spina/admin/conferences/engine.rb +31 -0
  205. data/lib/spina/admin/conferences/migration/renaming.rb +79 -0
  206. data/lib/spina/admin/conferences/railtie.rb +34 -0
  207. data/lib/spina/admin/conferences/version.rb +10 -0
  208. data/lib/spina/admin/conferences.rb +23 -0
  209. data/lib/tasks/spina/admin/conferences_tasks.rake +14 -0
  210. metadata +603 -0
@@ -0,0 +1,134 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spina
4
+ module Admin
5
+ module Conferences
6
+ # Presentation records.
7
+ #
8
+ # = Validators
9
+ # Presence:: {#title}, {#date}, {#start_time}, {#start_datetime}, {#abstract}, {#presenters}.
10
+ # Conference date (using {ConferenceDateValidator}):: {#date}.
11
+ # @see ConferenceDateValidator
12
+ #
13
+ # = Translations
14
+ # - {#name}
15
+ # - {#title}
16
+ # - {#abstract}
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
+
26
+ default_scope { includes(:translations) }
27
+
28
+ # @!attribute [rw] title
29
+ # @return [String, nil] the presentation title
30
+ # @!attribute [rw] abstract
31
+ # @return [ActionText::RichText, nil] the presentation abstract
32
+ translates :title, fallbacks: true
33
+ translates :abstract, backend: :action_text, fallbacks: true
34
+
35
+ # @return [ActiveRecord::Relation] all conferences, ordered by date
36
+ scope :sorted, -> { order start_datetime: :desc }
37
+
38
+ # @!attribute [rw] name
39
+ # @return [String, nil] the presentation title (alias)
40
+ # @see #title
41
+ alias_attribute :name, :title
42
+
43
+ # @!attribute [rw] session
44
+ # @return [Session, nil] directly associated session
45
+ # @see Session
46
+ belongs_to :session, -> { includes(:translations) }, inverse_of: :presentations, touch: true
47
+ # @!attribute [rw] presentation_type
48
+ # @return [PresentationType, nil] Presentation type associated with {#session}
49
+ # @see PresentationType
50
+ # @see Session#presentation_type
51
+ has_one :presentation_type, -> { includes(:translations) }, through: :session
52
+ # @!attribute [rw] room
53
+ # @return [Room, nil] Room associated with {#session}
54
+ # @see Session
55
+ # @see Session#room
56
+ has_one :room, -> { includes(:translations) }, through: :session
57
+ # @!attribute [rw] conference
58
+ # @return [Conference, nil] Conference associated with {#presentation_type}
59
+ # @see Conference
60
+ # @see PresentationType#conference
61
+ has_one :conference, -> { includes(:translations) }, through: :presentation_type
62
+ # @!attribute [rw] attachments
63
+ # @return [ActiveRecord::Relation] directly associated presentation attachments
64
+ # @note This relation accepts nested attributes.
65
+ # @note Destroying a presentation destroys associated attachments.
66
+ # @see Attachment
67
+ has_many :attachments, class_name: 'Spina::Admin::Conferences::PresentationAttachment', dependent: :destroy,
68
+ inverse_of: :presentation
69
+ # @!attribute [rw] presenters
70
+ # @return [ActiveRecord::Relation] directly associated delegates
71
+ # @see Delegate
72
+ has_and_belongs_to_many :presenters, class_name: 'Spina::Admin::Conferences::Delegate', # rubocop:disable Rails/HasAndBelongsToMany
73
+ foreign_key: :spina_conferences_presentation_id,
74
+ association_foreign_key: :spina_conferences_delegate_id
75
+ accepts_nested_attributes_for :attachments, allow_destroy: true
76
+
77
+ validates :title, :start_datetime, :abstract, :presenters, presence: true
78
+ validates :start_datetime, 'spina/admin/conferences/conference_date': true
79
+ validates_associated :presenters
80
+ validates_associated :attachments
81
+
82
+ # @!attribute [rw] start_time
83
+ # @return [ActiveSupport::TimeWithZone, nil] the start time (alias)
84
+ # @see #start_datetime
85
+ alias_attribute :start_time, :start_datetime
86
+
87
+ # Imports a presentation from CSV.
88
+ # @param file [String] the CSV file to be read
89
+ # @return [void]
90
+ # @see PresentationImportJob#perform
91
+ def self.import(file)
92
+ PresentationImportJob.perform_later IO.read(file)
93
+ end
94
+
95
+ # @return [Date, nil] the start date of the presentation. Nil if the presentation has no start date and time
96
+ def date
97
+ return if start_datetime.blank?
98
+
99
+ start_datetime.to_date
100
+ end
101
+
102
+ # @return [ActiveSupport::TimeWithZone, nil] the presentation end time. Nil if the presentation has no start date and time
103
+ def finish_datetime
104
+ return if start_datetime.blank?
105
+
106
+ start_datetime + presentation_type.duration
107
+ end
108
+
109
+ # @return [TZInfo::TimezonePeriod, nil] the time zone period for the presentation
110
+ def time_zone_period
111
+ return if start_datetime.blank?
112
+
113
+ start_datetime.period
114
+ end
115
+
116
+ # @return [Icalendar::Event] the presentation as an iCal event
117
+ def to_event # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
118
+ event = Icalendar::Event.new
119
+ return event if invalid?
120
+
121
+ event.dtstart = Icalendar::Values::DateTime.new(start_datetime, tzid: start_datetime.time_zone.tzinfo.name)
122
+ event.dtend = Icalendar::Values::DateTime.new(finish_datetime, tzid: finish_datetime.time_zone.tzinfo.name)
123
+ event.location = session.room_name
124
+ presenters.each { |presenter| event.contact = presenter.full_name_and_institution }
125
+ event.categories = Presentation.model_name.human(count: 0)
126
+ event.summary = title
127
+ event.append_custom_property('alt_description', abstract.to_s)
128
+ event.description = abstract.try(:to_plain_text)
129
+ event
130
+ end
131
+ end
132
+ end
133
+ end
134
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spina
4
+ module Admin
5
+ module Conferences
6
+ # Presentation attachment records.
7
+ class PresentationAttachment < ApplicationRecord
8
+ # @!attribute [rw] presentation
9
+ # @return [Presentation, nil] directly associated presentation
10
+ belongs_to :presentation, -> { includes(:translations) }, inverse_of: :attachments, touch: true
11
+ # @!attribute [rw] presentation_attachment_type
12
+ # @return [PresentationAttachmentType, nil] directly associated presentation attachment type
13
+ belongs_to :attachment_type, -> { includes(:translations) }, class_name: 'Spina::Admin::Conferences::PresentationAttachmentType',
14
+ inverse_of: :presentation_attachments,
15
+ touch: true
16
+ # @!attribute [rw] attachment
17
+ # @return [Spina::Attachment, nil] directly associated attachment
18
+ belongs_to :attachment, class_name: 'Spina::Attachment'
19
+
20
+ # @!method name
21
+ # @return [String, nil] name of associated presentation attachment type
22
+ # @note Delegated to {#presentation_attachment_type}.
23
+ delegate :name, to: :attachment_type, allow_nil: true
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spina
4
+ module Admin
5
+ module Conferences
6
+ # Presentation attachment type records.
7
+ #
8
+ # = Validators
9
+ # Presence:: {#name}.
10
+ #
11
+ # = Translations
12
+ # - {#name}
13
+ class PresentationAttachmentType < ApplicationRecord
14
+ default_scope { includes(:translations) }
15
+
16
+ # @!attribute [rw] name
17
+ # @return [String, nil] the name of the presentation attachment type
18
+ translates :name, fallbacks: true
19
+
20
+ # @return [ActiveRecord::Relation] all presentation attachment types, ordered by name
21
+ scope :sorted, -> { i18n.order :name }
22
+
23
+ # @!attribute [rw] presentation_attachments
24
+ # @return [ActiveRecord::Relation] directly associated presentation attachments
25
+ # @see PresentationAttachment
26
+ has_many :presentation_attachments, class_name: 'Spina::Admin::Conferences::PresentationAttachment',
27
+ foreign_key: 'attachment_type_id',
28
+ dependent: :destroy,
29
+ inverse_of: :attachment_type
30
+
31
+ validates :name, presence: true
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spina
4
+ module Admin
5
+ module Conferences
6
+ # Presentation type records.
7
+ #
8
+ # = Validators
9
+ # Presence:: {#name}, {#minutes}. {#duration}.
10
+ #
11
+ # = Translations
12
+ # - {#name}
13
+ class PresentationType < ApplicationRecord
14
+ default_scope { includes(:translations) }
15
+
16
+ # @!attribute [rw] name
17
+ # @return [String, nil] the name of the presentation type
18
+ translates :name, fallbacks: true
19
+
20
+ # @return [ActiveRecord::Relation] all presentation types, ordered by name
21
+ scope :sorted, -> { i18n.order :name }
22
+
23
+ # @!attribute [rw] duration
24
+ # @return [ActiveSupport::Duration, nil] the duration of dependent presentations
25
+ attribute :duration, :interval
26
+
27
+ # @!attribute [rw] conference
28
+ # @return [Conference, nil] directly associated conference
29
+ belongs_to :conference, -> { includes(:translations) }, inverse_of: :presentation_types, touch: true
30
+ # @!attribute [rw] sessions
31
+ # @return [ActiveRecord::Relation] directly associated sessions
32
+ # @note A presentation type cannot be destroyed if it has dependent sessions.
33
+ # @see Session
34
+ has_many :sessions, -> { includes(:translations) }, inverse_of: :presentation_type, dependent: :restrict_with_error
35
+ # @!attribute [rw] presentations
36
+ # @return [ActiveRecord::Relation] Presentations associated with {#sessions}
37
+ # @see Presentation
38
+ # @see Session#presentations
39
+ has_many :presentations, -> { distinct.includes(:translations) }, through: :sessions
40
+
41
+ validates :name, :minutes, :duration, presence: true
42
+ validates :minutes, numericality: { greater_than_or_equal_to: 1 }
43
+
44
+ # @return [Integer, nil] duration in minutes. Nil if the conference has no duration
45
+ def minutes
46
+ return if duration.blank?
47
+
48
+ duration.to_i / ActiveSupport::Duration::PARTS_IN_SECONDS[:minutes]
49
+ end
50
+
51
+ # Sets the duration of the conference.
52
+ # @param minutes [#to_i] the new duration in minutes
53
+ # @return [void]
54
+ def minutes=(minutes)
55
+ self.duration = minutes.to_i.minutes
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spina
4
+ module Admin
5
+ module Conferences
6
+ # Room records.
7
+ #
8
+ # = Validators
9
+ # Presence:: {#number}, {#building}.
10
+ #
11
+ # = Translations
12
+ # - {#number}
13
+ # - {#building}
14
+ class Room < ApplicationRecord
15
+ default_scope { includes(:translations) }
16
+
17
+ # @!attribute [rw] number
18
+ # @return [String, nil] the number of the room
19
+ # @!attribute [rw] building
20
+ # @return [String, nil] the building of the room
21
+ translates :building, :number, fallbacks: true
22
+
23
+ # @return [ActiveRecord::Relation] all rooms, ordered by building and number
24
+ scope :sorted, -> { i18n.order :building, :number }
25
+
26
+ # @!attribute [rw] institution
27
+ # @return [Institution, nil] directly associated institution
28
+ # @see Institution
29
+ belongs_to :institution, -> { includes(:translations) }, inverse_of: :rooms, autosave: true, touch: true
30
+ # @!attribute [rw] sessions
31
+ # @return [ActiveRecord::Relation] directly associated sessions
32
+ # @note A room cannot be destroyed if it has dependent sessions.
33
+ # @see Session
34
+ has_many :sessions, -> { includes(:translations) }, inverse_of: :room, dependent: :restrict_with_error
35
+ # @!attribute [rw] presentations
36
+ # @return [ActiveRecord::Relation] Presentations associated with {#sessions}
37
+ # @see Presentation
38
+ # @see Session#presentations
39
+ has_many :presentations, -> { distinct.includes(:translations) }, through: :sessions
40
+
41
+ validates :number, :building, presence: true
42
+
43
+ # @return [String] the building and number of the room
44
+ def name
45
+ return if building.blank? || number.blank?
46
+
47
+ Room.human_attribute_name :name, building: building, number: number
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spina
4
+ module Admin
5
+ module Conferences
6
+ # Session records.
7
+ #
8
+ # = Validators
9
+ # Presence:: {#name}.
10
+ #
11
+ # = Translations
12
+ # - {#name}
13
+ class Session < ApplicationRecord
14
+ default_scope { includes(:translations) }
15
+
16
+ # @!attribute [rw] name
17
+ # @return [String, nil] the name of the session
18
+ translates :name, fallbacks: true
19
+
20
+ # @!attribute [rw] room
21
+ # @return [Room, nil] directly associated room
22
+ belongs_to :room, -> { includes(:translations) }, inverse_of: :sessions, touch: true
23
+ # @!attribute [rw] room
24
+ # @return [PresentationType, nil] directly associated presentation type
25
+ # @see PresentationType
26
+ belongs_to :presentation_type, -> { includes(:translations) }, inverse_of: :sessions, touch: true
27
+ # @!attribute [rw] conference
28
+ # @return [Conference, nil] Conference associated with {#presentation_type}
29
+ # @see Conference
30
+ # @see PresentationType#conference
31
+ has_one :conference, -> { includes(:translations) }, through: :presentation_type
32
+ # @!attribute [rw] institution
33
+ # @return [Institution, nil] Institution associated with {#room}
34
+ # @see Institution
35
+ # @see Room#institution
36
+ has_one :institution, -> { includes(:translations) }, through: :room
37
+ # @!attribute [rw] presentations
38
+ # @return [ActiveRecord::Relation] directly associated presentations
39
+ # @note A session cannot be destroyed if it has dependent presentations.
40
+ # @see Presentation
41
+ has_many :presentations, inverse_of: :session, dependent: :restrict_with_error
42
+
43
+ validates :name, presence: true
44
+
45
+ # @!method room_name
46
+ # @return [String, nil] name of associated room
47
+ # @note Delegated to {#room}.
48
+ delegate :name, to: :room, prefix: true, allow_nil: true
49
+ # @!method presentation_type_name
50
+ # @return [String, nil] name of associated presentation type
51
+ # @note Delegated to {#presentation_type}.
52
+ delegate :name, to: :presentation_type, prefix: true, allow_nil: true
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spina
4
+ module Admin
5
+ module Conferences # rubocop:disable Style/Documentation
6
+ def self.table_name_prefix
7
+ 'spina_conferences_'
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spina
4
+ module Parts
5
+ module Admin
6
+ module Conferences
7
+ # Date parts, without associated times.
8
+ class Date < Spina::Parts::Base
9
+ attr_json :content, :date
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spina
4
+ module Parts
5
+ module Admin
6
+ module Conferences
7
+ # Email address parts. The format is validated.
8
+ #
9
+ # = Validators
10
+ # Email address (using {EmailAddressValidator}):: {#content}.
11
+ # @see EmailAddressValidator
12
+ class EmailAddress < Spina::Parts::Base
13
+ attr_json :content, :string
14
+
15
+ validates :content, 'spina/admin/conferences/email_address': true, allow_blank: true
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spina
4
+ module Parts
5
+ module Admin
6
+ module Conferences
7
+ # Time parts.
8
+ class Time < Spina::Parts::Base
9
+ attr_json :content, :time
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spina
4
+ module Parts
5
+ module Admin
6
+ module Conferences
7
+ # URL parts. The format is validated.
8
+ #
9
+ # = Validators
10
+ # HTTP(S) URL (using {HttpUrlValidator}):: {#content}.
11
+ # @see HttpUrlValidator
12
+ class Url < Spina::Parts::Base
13
+ attr_json :content, :string
14
+
15
+ validates :content, 'spina/admin/conferences/http_url': true, allow_blank: true
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spina
4
+ module Admin
5
+ module Conferences
6
+ # Validator for dates which should occur during the associated conference.
7
+ class ConferenceDateValidator < ActiveModel::EachValidator
8
+ # Performs validation on the supplied record.
9
+ # @param record [ActiveRecord::Base] the associated record
10
+ # @param attribute [Symbol] the attribute key
11
+ # @param value [Date] the attribute value
12
+ def validate_each(record, attribute, value)
13
+ return if value.blank? || record.conference&.dates&.cover?(value.to_date)
14
+
15
+ record.errors.add(attribute, :outside_conference)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spina
4
+ module Admin
5
+ module Conferences
6
+ # Validator for email addresses.
7
+ class EmailAddressValidator < ActiveModel::EachValidator
8
+ # Performs validation on the supplied record.
9
+ # @param record [ActiveRecord::Base] the associated record
10
+ # @param attribute [Symbol] the attribute key
11
+ # @param value [String] the attribute value
12
+ def validate_each(record, attribute, value)
13
+ return if value.blank?
14
+
15
+ record.errors.add(attribute, :invalid_email_address) unless parse(value)
16
+ end
17
+
18
+ private
19
+
20
+ def parse(value)
21
+ Mail::Address.new(value).then { |address| address.domain.present? && address.local.present? }
22
+ rescue Mail::Field::IncompleteParseError
23
+ false
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spina
4
+ module Admin
5
+ module Conferences
6
+ # Validator for dates which should occur after a +start_date+.
7
+ class FinishDateValidator < ActiveModel::EachValidator
8
+ # Performs validation on the supplied record.
9
+ # @param record [ActiveRecord::Base] the associated record
10
+ # @param attribute [Symbol] the attribute key
11
+ # @param value [Date] the attribute value
12
+ def validate_each(record, attribute, value)
13
+ return if value.blank? || record.start_date.blank? || value >= record.start_date
14
+
15
+ record.errors.add(attribute, :before_start_date)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spina
4
+ module Admin
5
+ module Conferences
6
+ # Validator for times which should occur after a +start_time+.
7
+ class FinishTimeValidator < ActiveModel::EachValidator
8
+ # Performs validation on the supplied record.
9
+ # @param record [ActiveRecord::Base] the associated record
10
+ # @param attribute [Symbol] the attribute key
11
+ # @param value [Time] the attribute value
12
+ def validate_each(record, attribute, value)
13
+ return if value.blank? || record.start_time.blank? || value >= record.start_time
14
+
15
+ record.errors.add(attribute, :before_start_time)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spina
4
+ module Admin
5
+ module Conferences
6
+ # Validator for HTTP(S) URLs.
7
+ class HttpUrlValidator < ActiveModel::EachValidator
8
+ # Performs validation on the supplied record.
9
+ # @param record [ActiveRecord::Base] the associated record
10
+ # @param attribute [Symbol] the attribute key
11
+ # @param value [String] the attribute value
12
+ def validate_each(record, attribute, value)
13
+ return if value.blank?
14
+
15
+ record.errors.add(attribute, :invalid_http_https_url) unless parse(value)
16
+ end
17
+
18
+ private
19
+
20
+ def parse(value)
21
+ URI.parse(value).then { |uri| uri.is_a?(URI::HTTP) && uri.host.present? }
22
+ rescue URI::InvalidURIError
23
+ false
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,6 @@
1
+ - content_for :application do
2
+ %div{ data: { turbolinks: 'false' } }
3
+ = yield(:admin_header)
4
+ = yield
5
+
6
+ = render template: 'layouts/spina/admin/admin'
@@ -0,0 +1,17 @@
1
+ - content_for :admin_header do
2
+ %header#header
3
+ #header_actions
4
+ = yield(:header_actions)
5
+
6
+ = render partial: 'spina/admin/shared/breadcrumbs'
7
+
8
+ %nav#secondary.tabs
9
+ %ul
10
+ %li{class: ('active' if controller_name == 'conferences')}
11
+ = link_to Spina::Admin::Conferences::Conference.model_name.human(count: 0), admin_conferences_conferences_path
12
+ %li{class: ('active' if controller_name == 'presentation_types')}
13
+ = link_to Spina::Admin::Conferences::PresentationType.model_name.human(count: 0), admin_conferences_presentation_types_path
14
+ %li{class: ('active' if controller_name == 'sessions')}
15
+ = link_to Spina::Admin::Conferences::Session.model_name.human(count: 0), admin_conferences_sessions_path
16
+
17
+ = render template: 'layouts/spina/admin/conferences/application'
@@ -0,0 +1,8 @@
1
+ - content_for :admin_header do
2
+ %header#header
3
+ #header_actions
4
+ = yield(:header_actions)
5
+
6
+ = render partial: 'spina/admin/shared/breadcrumbs'
7
+
8
+ = render template: 'layouts/spina/admin/conferences/application'
@@ -0,0 +1,8 @@
1
+ - content_for :admin_header do
2
+ %header#header
3
+ #header_actions
4
+ = yield(:header_actions)
5
+
6
+ = render partial: 'spina/admin/shared/breadcrumbs'
7
+
8
+ = render template: 'layouts/spina/admin/conferences/application'
@@ -0,0 +1,15 @@
1
+ - content_for :admin_header do
2
+ %header#header
3
+ #header_actions
4
+ = yield(:header_actions)
5
+
6
+ = render partial: 'spina/admin/shared/breadcrumbs'
7
+
8
+ %nav#secondary.tabs
9
+ %ul
10
+ %li{class: ('active' if controller_name == 'institutions')}
11
+ = link_to Spina::Admin::Conferences::Institution.model_name.human(count: 0), admin_conferences_institutions_path
12
+ %li{class: ('active' if controller_name == 'rooms')}
13
+ = link_to Spina::Admin::Conferences::Room.model_name.human(count: 0), admin_conferences_rooms_path
14
+
15
+ = render template: 'layouts/spina/admin/conferences/application'
@@ -0,0 +1,8 @@
1
+ - content_for :admin_header do
2
+ %header#header
3
+ #header_actions
4
+ = yield(:header_actions)
5
+
6
+ = render partial: 'spina/admin/shared/breadcrumbs'
7
+
8
+ = render template: 'layouts/spina/admin/conferences/application'
@@ -0,0 +1,8 @@
1
+ - content_for :admin_header do
2
+ %header#header
3
+ #header_actions
4
+ = yield(:header_actions)
5
+
6
+ = render partial: 'spina/admin/shared/breadcrumbs'
7
+
8
+ = render template: 'layouts/spina/admin/conferences/application'
@@ -0,0 +1,12 @@
1
+ .well
2
+ .table-container
3
+ %table.table
4
+ %thead
5
+ %tr
6
+ %th= Spina::Admin::Conferences::Conference.human_attribute_name :name
7
+ %th= Spina::Admin::Conferences::Conference.human_attribute_name :year
8
+ %th= Spina::Admin::Conferences::Conference.human_attribute_name :start_date
9
+ %th= Spina::Admin::Conferences::Conference.human_attribute_name :finish_date
10
+ %th
11
+
12
+ %tbody= render conferences.presence || 'empty_list', message: t('.no_conferences')