lcms-engine 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +11 -15
  4. data/Dockerfile +0 -1
  5. data/README.md +13 -4
  6. data/app/assets/javascripts/lcms/engine/admin/application.js +2 -6
  7. data/app/assets/javascripts/lcms/engine/application.js +2 -2
  8. data/app/assets/javascripts/lcms/engine/initializers/{google_analytics.js → analytics.js} +0 -0
  9. data/app/assets/javascripts/lcms/engine/initializers/lessons.js +1 -1
  10. data/app/assets/stylesheets/lcms/engine/admin.scss +1 -1
  11. data/app/assets/stylesheets/lcms/engine/application.scss +4 -3
  12. data/app/assets/stylesheets/lcms/engine/components/_curriculum-cards.scss +1 -1
  13. data/app/assets/stylesheets/lcms/engine/components/_curriculum-map.scss +4 -4
  14. data/app/assets/stylesheets/lcms/engine/components/_media-resources.scss +1 -1
  15. data/app/assets/stylesheets/lcms/engine/components/_panel-dsc.scss +1 -1
  16. data/app/assets/stylesheets/lcms/engine/components/_resource.scss +6 -6
  17. data/app/assets/stylesheets/lcms/engine/pages/_home.scss +4 -4
  18. data/app/assets/stylesheets/lcms/engine/pdf.scss +1 -1
  19. data/app/assets/stylesheets/lcms/engine/themes/_settings.scss +419 -116
  20. data/app/assets/stylesheets/lcms/engine/utils/_mixins.scss +2 -2
  21. data/app/assets/stylesheets/lcms/engine/vendors/foundation_and_overrides-pdf.scss +0 -1
  22. data/app/assets/stylesheets/lcms/engine/vendors/foundation_and_overrides.scss +13 -2
  23. data/app/controllers/lcms/engine/admin/admin_controller.rb +0 -2
  24. data/app/controllers/lcms/engine/admin/association_picker_controller.rb +10 -9
  25. data/app/controllers/lcms/engine/admin/documents_controller.rb +17 -14
  26. data/app/controllers/lcms/engine/admin/materials_controller.rb +19 -23
  27. data/app/controllers/lcms/engine/admin/resource_picker_controller.rb +2 -2
  28. data/app/controllers/lcms/engine/admin/resources_controller.rb +45 -79
  29. data/app/controllers/lcms/engine/admin/sketch_compilers_controller.rb +2 -2
  30. data/app/controllers/lcms/engine/application_controller.rb +0 -15
  31. data/app/entities/lcms/engine/pagination.rb +14 -5
  32. data/app/forms/lcms/engine/material_form.rb +0 -1
  33. data/app/helpers/lcms/engine/application_helper.rb +2 -6
  34. data/app/helpers/lcms/engine/view_helper.rb +1 -3
  35. data/app/interactors/lcms/engine/explore_curriculum_interactor.rb +1 -1
  36. data/app/javascript/components/admin/ImportStatus.jsx +1 -1
  37. data/app/javascript/components/admin/association-picker/AssociationPickerResults.jsx +1 -1
  38. data/app/javascript/components/admin/picker/pickerWindowWrapper.jsx +0 -1
  39. data/app/models/lcms/engine/access_code.rb +1 -1
  40. data/app/models/lcms/engine/application_record.rb +9 -0
  41. data/app/models/lcms/engine/author.rb +1 -1
  42. data/app/models/lcms/engine/copyright_attribution.rb +1 -1
  43. data/app/models/lcms/engine/curriculum.rb +1 -1
  44. data/app/models/lcms/engine/document.rb +3 -3
  45. data/app/models/lcms/engine/document_bundle.rb +2 -2
  46. data/app/models/lcms/engine/document_part.rb +1 -1
  47. data/app/models/lcms/engine/download.rb +3 -3
  48. data/app/models/lcms/engine/download_category.rb +1 -1
  49. data/app/models/lcms/engine/leadership_post.rb +1 -1
  50. data/app/models/lcms/engine/material.rb +2 -2
  51. data/app/models/lcms/engine/material_part.rb +1 -1
  52. data/app/models/lcms/engine/page.rb +1 -1
  53. data/app/models/lcms/engine/reading_assignment_author.rb +1 -1
  54. data/app/models/lcms/engine/reading_assignment_text.rb +1 -1
  55. data/app/models/lcms/engine/resource.rb +4 -12
  56. data/app/models/lcms/engine/resource_additional_resource.rb +1 -1
  57. data/app/models/lcms/engine/resource_download.rb +1 -1
  58. data/app/models/lcms/engine/resource_reading_assignment.rb +1 -1
  59. data/app/models/lcms/engine/resource_related_resource.rb +1 -1
  60. data/app/models/lcms/engine/resource_standard.rb +1 -1
  61. data/app/models/lcms/engine/search/elastic_search_document.rb +1 -1
  62. data/app/models/lcms/engine/settings.rb +1 -1
  63. data/app/models/lcms/engine/social_thumbnail.rb +1 -1
  64. data/app/models/lcms/engine/staff_member.rb +1 -1
  65. data/app/models/lcms/engine/standard.rb +1 -1
  66. data/app/models/lcms/engine/standard_link.rb +1 -1
  67. data/app/models/lcms/engine/user.rb +3 -3
  68. data/app/presenters/lcms/engine/content_presenter.rb +1 -1
  69. data/app/queries/lcms/engine/admin_documents_query.rb +1 -1
  70. data/app/queries/lcms/engine/admin_materials_query.rb +1 -1
  71. data/app/serializers/lcms/engine/association_item_serializer.rb +0 -1
  72. data/app/serializers/lcms/engine/curriculum_resource_serializer.rb +0 -2
  73. data/app/serializers/lcms/engine/document_material_serializer.rb +0 -1
  74. data/app/serializers/lcms/engine/material_serializer.rb +0 -1
  75. data/app/serializers/lcms/engine/previews_material_serializer.rb +0 -1
  76. data/app/serializers/lcms/engine/resource_details_serializer.rb +0 -2
  77. data/app/serializers/lcms/engine/resource_instruction_serializer.rb +0 -2
  78. data/app/serializers/lcms/engine/resource_picker_serializer.rb +0 -2
  79. data/app/serializers/lcms/engine/resource_serializer.rb +0 -2
  80. data/app/serializers/lcms/engine/search_document_serializer.rb +0 -2
  81. data/app/services/lcms/engine/document_build_service.rb +1 -0
  82. data/app/services/lcms/engine/html_sanitizer.rb +2 -2
  83. data/app/services/lcms/engine/s3_service.rb +1 -1
  84. data/app/uploaders/social_thumbnail_uploader.rb +0 -4
  85. data/app/views/layouts/lcms/engine/admin.html.erb +1 -1
  86. data/app/views/lcms/engine/admin/access_codes/index.html.erb +10 -8
  87. data/app/views/lcms/engine/admin/documents/index.html.erb +2 -2
  88. data/app/views/lcms/engine/admin/materials/index.html.erb +2 -2
  89. data/app/views/lcms/engine/admin/pages/index.html.erb +3 -3
  90. data/app/views/lcms/engine/admin/standards/index.html.erb +9 -7
  91. data/app/views/lcms/engine/admin/users/index.html.erb +16 -14
  92. data/app/views/lcms/engine/resources/_children_list.html.erb +1 -1
  93. data/app/views/lcms/engine/shared/_social_sharing_menu.html.erb +4 -4
  94. data/config/initializers/carrier_wave.rb +0 -1
  95. data/config/locales/admin/en.yml +0 -2
  96. data/db/migrate/20200422130652_add_reimported_at_to_documents.rb +7 -0
  97. data/lcms-engine.gemspec +73 -87
  98. data/lib/doc_template/document.rb +2 -2
  99. data/lib/doc_template/tables/activity.rb +2 -1
  100. data/lib/doc_template/tables/base.rb +0 -4
  101. data/lib/doc_template/tables/section.rb +2 -1
  102. data/lib/doc_template/tags/link_tag.rb +1 -1
  103. data/lib/doc_template/xpath_functions.rb +1 -3
  104. data/lib/document_exporter/base.rb +1 -2
  105. data/lib/document_exporter/docx.rb +0 -1
  106. data/lib/generators/lcms/engine/install/install_generator.rb +1 -4
  107. data/lib/generators/lcms/engine/install/templates/config/lcms.yml +1 -1
  108. data/lib/lcms/engine/engine.rb +0 -16
  109. data/lib/lcms/engine/migration.rb +2 -0
  110. data/lib/lcms/engine/version.rb +1 -1
  111. data/lib/lt/lcms/metadata/context.rb +7 -5
  112. data/spec/controllers/admin/admin_controller_spec.rb +1 -1
  113. data/spec/controllers/admin/association_picker_controller_spec.rb +2 -2
  114. data/spec/controllers/admin/curriculums_controller_spec.rb +1 -2
  115. data/spec/controllers/admin/documents_controller_spec.rb +12 -41
  116. data/spec/controllers/admin/materials_controller_spec.rb +7 -67
  117. data/spec/controllers/admin/pages_controller_spec.rb +2 -2
  118. data/spec/controllers/admin/resource_bulk_edit_controller_spec.rb +3 -3
  119. data/spec/controllers/admin/sketch_compilers_controller_spec.rb +5 -4
  120. data/spec/controllers/admin/standards_controller_spec.rb +12 -9
  121. data/spec/controllers/admin/users_controller_spec.rb +2 -2
  122. data/spec/controllers/admin/welcome_controller_spec.rb +1 -1
  123. data/spec/controllers/documents_controller_spec.rb +3 -3
  124. data/spec/controllers/enhance_instruction_controller_spec.rb +1 -1
  125. data/spec/controllers/explore_curriculum_controller_spec.rb +2 -2
  126. data/spec/controllers/find_lessons_controller_spec.rb +1 -1
  127. data/spec/controllers/pages_controller_spec.rb +9 -12
  128. data/spec/controllers/resources_controller_spec.rb +2 -2
  129. data/spec/controllers/search_controller_spec.rb +1 -1
  130. data/spec/dummy/bin/spring +2 -2
  131. data/spec/dummy/config/application.rb +3 -3
  132. data/spec/dummy/config/environments/test.rb +2 -5
  133. data/spec/dummy/config/lcms-admin.yml +3 -3
  134. data/spec/dummy/config/webpack/development.js +5 -0
  135. data/spec/dummy/config/webpack/environment.js +3 -0
  136. data/spec/dummy/config/webpack/production.js +5 -0
  137. data/spec/dummy/config/webpack/test.js +5 -0
  138. data/spec/dummy/config/webpacker.yml +96 -0
  139. data/spec/dummy/db/schema.rb +251 -275
  140. data/spec/factories/document_bundles.rb +1 -1
  141. data/spec/factories/standard_links.rb +2 -0
  142. data/spec/factories/taggings.rb +1 -0
  143. data/spec/models/document_bundle_spec.rb +0 -6
  144. data/spec/models/resource_spec.rb +0 -33
  145. data/spec/rails_helper.rb +0 -1
  146. data/spec/requests/admin/curriculum_spec.rb +17 -0
  147. data/spec/services/document_build_service_spec.rb +76 -62
  148. data/spec/services/html_sanitizer_spec.rb +0 -34
  149. data/spec/support/capybara.rb +1 -3
  150. data/spec/support/concerns/searchable.rb +2 -0
  151. data/spec/support/database_cleaner.rb +5 -16
  152. data/spec/support/devise.rb +2 -0
  153. data/yarn.lock +442 -530
  154. metadata +183 -439
  155. data/Gemfile.lock +0 -752
  156. data/config/initializers/active_record.rb +0 -3
  157. data/spec/controllers/admin/resources_controller_spec.rb +0 -84
  158. data/spec/fixtures/tables/activity-metadata-3activities.html +0 -1
  159. data/spec/fixtures/tables/document-metadata-2paragpraphs.html +0 -97
  160. data/spec/fixtures/tables/document-metadata-2spans.html +0 -96
  161. data/spec/fixtures/tables/document-metadata.html +0 -96
  162. data/spec/lib/doc_template/tables/activity_spec.rb +0 -28
  163. data/spec/lib/doc_template/tables/metadata_spec.rb +0 -40
  164. data/spec/lib/doc_template/tables/shared_examples/remove_table.rb +0 -11
  165. data/spec/support/fixture_helper.rb +0 -16
@@ -3,15 +3,16 @@
3
3
  module Lcms
4
4
  module Engine
5
5
  class Pagination
6
+ PARAMS_DEFAULT = { page: 1, per_page: 20, order: :asc }.freeze
7
+
6
8
  def initialize(params)
7
- @params = params
9
+ @params = handle_params params
8
10
  end
9
11
 
10
12
  def params(strict: false)
11
13
  @pagination_params ||= begin
12
- default_params = { page: 1, per_page: 20, order: :asc }
13
- expected_params = @params.slice(:page, :per_page, :order).symbolize_keys
14
- pagination = default_params.merge(expected_params)
14
+ expected_params = @params.slice(*PARAMS_DEFAULT.keys).symbolize_keys
15
+ pagination = PARAMS_DEFAULT.merge(expected_params)
15
16
 
16
17
  pagination[:page] = pagination[:page].to_i
17
18
  pagination[:per_page] = pagination[:per_page].to_i
@@ -37,7 +38,15 @@ module Lcms
37
38
  total_hits: resources.total_entries
38
39
  }
39
40
  options[:each_serializer] = serializer
40
- ActiveModel::ArraySerializer.new(resources, options).as_json
41
+ ActiveModel::Serializer::CollectionSerializer.new(resources, options).as_json
42
+ end
43
+
44
+ private
45
+
46
+ def handle_params(params)
47
+ return params unless params.is_a?(ActionController::Parameters)
48
+
49
+ params.permit(*PARAMS_DEFAULT.keys).to_h
41
50
  end
42
51
  end
43
52
  end
@@ -22,7 +22,6 @@ module Lcms
22
22
  return false unless valid?
23
23
 
24
24
  params = {
25
- dpi: options[:dpi],
26
25
  import_retry: options[:import_retry],
27
26
  source_type: source_type.presence
28
27
  }.compact
@@ -8,12 +8,8 @@ module Lcms
8
8
  include ViewHelper
9
9
  include ::Webpacker::Helper
10
10
 
11
- # Use this to include lcms-engine based packs
12
- def lcms_engine_javascript_pack_tag(*names, **options)
13
- entries = names
14
- .map { |name| Lcms::Engine.webpacker.manifest.lookup!(name, type: :javascript) }
15
- .flatten
16
- javascript_include_tag(*entries, **options)
11
+ def current_webpacker_instance
12
+ Lcms::Engine.webpacker
17
13
  end
18
14
  end
19
15
  end
@@ -3,9 +3,7 @@
3
3
  module Lcms
4
4
  module Engine
5
5
  module ViewHelper # rubocop:disable Metrics/ModuleLength
6
- ENABLE_BASE64_CACHING = ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include?(
7
- ENV.fetch('ENABLE_BASE64_CACHING', true)
8
- )
6
+ ENABLE_BASE64_CACHING = ActiveRecord::Type::Boolean.new.cast ENV.fetch('ENABLE_BASE64_CACHING', true)
9
7
 
10
8
  def add_class_for_path(link_path, klass, klass_prefix = nil)
11
9
  [
@@ -32,7 +32,7 @@ module Lcms
32
32
  end
33
33
 
34
34
  def grades_props
35
- ActiveModel::ArraySerializer.new(
35
+ ActiveModel::Serializer::CollectionSerializer.new(
36
36
  grades,
37
37
  each_serializer: CurriculumResourceSerializer,
38
38
  root: :results
@@ -75,7 +75,7 @@ class ImportStatus extends React.Component {
75
75
  }
76
76
 
77
77
  spinner() {
78
- return <span className="o-adm-materials__spinner button primary u-margin-bottom--zero"><i className="fa fa-spin fa-spinner" /></span>
78
+ return <span className="o-adm-materials__spinner button primary u-margin-bottom--zero"><i className="fas fa-spin fa-spinner" /></span>
79
79
  }
80
80
 
81
81
  render() {
@@ -40,7 +40,7 @@ function AssociationPickerResults(props) {
40
40
  </tr>
41
41
  </thead>
42
42
  <tbody>
43
- {items}
43
+ {items.length ? items : <tr><td>Nothing to select</td></tr> }
44
44
  </tbody>
45
45
  </table>
46
46
  )
@@ -1,6 +1,5 @@
1
1
  import React from 'react'
2
2
  import PaginationBoxView from '../../paginate/PaginationBoxView'
3
- // import Routes from '../../../js-routes.js.erb';
4
3
 
5
4
  // eslint-disable-next-line no-unused-vars
6
5
  function pickerWindowWrapper(WrappedComponent, path) {
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Lcms
4
4
  module Engine
5
- class AccessCode < ActiveRecord::Base
5
+ class AccessCode < ApplicationRecord
6
6
  validates :code, presence: true, uniqueness: true
7
7
 
8
8
  scope :active, -> { where(active: true) }
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lcms
4
+ module Engine
5
+ class ApplicationRecord < ActiveRecord::Base
6
+ self.abstract_class = true
7
+ end
8
+ end
9
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Lcms
4
4
  module Engine
5
- class Author < ActiveRecord::Base
5
+ class Author < ApplicationRecord
6
6
  has_many :resources
7
7
  has_many :curriculums, -> { distinct }, through: :resources
8
8
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Lcms
4
4
  module Engine
5
- class CopyrightAttribution < ActiveRecord::Base
5
+ class CopyrightAttribution < ApplicationRecord
6
6
  belongs_to :resource
7
7
  validates :resource_id, :value, presence: true
8
8
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Lcms
4
4
  module Engine
5
- class Curriculum < ActiveRecord::Base
5
+ class Curriculum < ApplicationRecord
6
6
  has_many :resources, dependent: :nullify
7
7
  has_many :authors, -> { distinct }, through: :resources
8
8
 
@@ -2,11 +2,11 @@
2
2
 
3
3
  module Lcms
4
4
  module Engine
5
- class Document < ActiveRecord::Base
5
+ class Document < ApplicationRecord
6
6
  include Partable
7
7
  GOOGLE_URL_PREFIX = 'https://docs.google.com/document/d'
8
8
 
9
- belongs_to :resource
9
+ belongs_to :resource, optional: true
10
10
  has_many :document_parts, as: :renderer, dependent: :delete_all
11
11
  has_and_belongs_to_many :materials
12
12
 
@@ -55,7 +55,7 @@ module Lcms
55
55
  .joins('LEFT JOIN materials as m on m.id = links.key::integer')
56
56
  .where('((links.value -> ?)::text IS NULL) OR ((links.value -> ?)::text IS NULL)', 'gdoc', 'url')
57
57
  .where.not("m.metadata ->> 'type' = ?", 'pdf')
58
- .uniq
58
+ .distinct
59
59
  }
60
60
 
61
61
  scope :with_updated_materials, lambda {
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Lcms
4
4
  module Engine
5
- class DocumentBundle < ActiveRecord::Base
5
+ class DocumentBundle < ApplicationRecord
6
6
  CATEGORIES = %w(full tm sm).freeze
7
7
  CONTENT_TYPES = %w(pdf gdoc).freeze
8
8
 
@@ -10,7 +10,7 @@ module Lcms
10
10
 
11
11
  mount_uploader :file, DocumentBundleUploader
12
12
 
13
- validates :resource, :category, presence: true
13
+ validates :category, presence: true
14
14
  validates :category, inclusion: { in: CATEGORIES }
15
15
  validates :content_type, inclusion: { in: CONTENT_TYPES }
16
16
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Lcms
4
4
  module Engine
5
- class DocumentPart < ActiveRecord::Base
5
+ class DocumentPart < ApplicationRecord
6
6
  belongs_to :renderer, polymorphic: true
7
7
 
8
8
  enum context_type: { default: 0, gdoc: 1 }
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Lcms
4
4
  module Engine
5
- class Download < ActiveRecord::Base
5
+ class Download < ApplicationRecord
6
6
  CONTENT_TYPES = {
7
7
  zip: 'application/zip',
8
8
  pdf: 'application/pdf',
@@ -17,8 +17,8 @@ module Lcms
17
17
  alias_attribute :file, :filename
18
18
 
19
19
  validates :title, presence: true
20
- validates :file, presence: true, if: 'url.nil?'
21
- validates :url, presence: true, if: 'file.nil?'
20
+ validates :file, presence: true, if: -> { url.nil? }
21
+ validates :url, presence: true, if: -> { file.nil? }
22
22
 
23
23
  before_save :update_metadata
24
24
 
@@ -4,7 +4,7 @@ require 'acts_as_list'
4
4
 
5
5
  module Lcms
6
6
  module Engine
7
- class DownloadCategory < ActiveRecord::Base
7
+ class DownloadCategory < ApplicationRecord
8
8
  has_many :resource_downloads
9
9
 
10
10
  default_scope { order(:position) }
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Lcms
4
4
  module Engine
5
- class LeadershipPost < ActiveRecord::Base
5
+ class LeadershipPost < ApplicationRecord
6
6
  validates :first_name, :last_name, presence: true
7
7
  validates :description, length: { maximum: 4096 }
8
8
 
@@ -4,7 +4,7 @@ require 'pg_search'
4
4
 
5
5
  module Lcms
6
6
  module Engine
7
- class Material < ActiveRecord::Base
7
+ class Material < ApplicationRecord
8
8
  include PgSearch::Model
9
9
  include Partable
10
10
 
@@ -12,7 +12,7 @@ module Lcms
12
12
  validates :identifier, uniqueness: true
13
13
 
14
14
  has_many :document_parts, as: :renderer, dependent: :delete_all
15
- has_and_belongs_to_many :documents
15
+ has_and_belongs_to_many :documents, optional: true
16
16
 
17
17
  store_accessor :metadata
18
18
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Lcms
4
4
  module Engine
5
- class MaterialPart < ActiveRecord::Base
5
+ class MaterialPart < ApplicationRecord
6
6
  belongs_to :material
7
7
  enum context_type: { default: 0, gdoc: 1 }
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Lcms
4
4
  module Engine
5
- class Page < ActiveRecord::Base
5
+ class Page < ApplicationRecord
6
6
  validates :body, :title, :slug, presence: true
7
7
 
8
8
  def full_title
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Lcms
4
4
  module Engine
5
- class ReadingAssignmentAuthor < ActiveRecord::Base
5
+ class ReadingAssignmentAuthor < ApplicationRecord
6
6
  has_many :reading_assignment_texts
7
7
  end
8
8
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Lcms
4
4
  module Engine
5
- class ReadingAssignmentText < ActiveRecord::Base
5
+ class ReadingAssignmentText < ApplicationRecord
6
6
  has_many :resource_reading_assignments
7
7
  has_many :resources, through: :resource_reading_assignments
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Lcms
4
4
  module Engine
5
- class Resource < ActiveRecord::Base
5
+ class Resource < ApplicationRecord
6
6
  enum resource_type: {
7
7
  resource: 1,
8
8
  podcast: 2,
@@ -26,10 +26,10 @@ module Lcms
26
26
  acts_as_taggable_on :content_sources, :download_types, :resource_types, :tags, :topics
27
27
  has_closure_tree order: :level_position, dependent: :destroy, numeric_order: true
28
28
 
29
- belongs_to :parent, class_name: 'Lcms::Engine::Resource', foreign_key: 'parent_id'
29
+ belongs_to :parent, class_name: 'Lcms::Engine::Resource', foreign_key: 'parent_id', optional: true
30
30
 
31
- belongs_to :author
32
- belongs_to :curriculum
31
+ belongs_to :author, optional: true
32
+ belongs_to :curriculum, optional: true
33
33
 
34
34
  # Additional resources
35
35
  has_many :resource_additional_resources, dependent: :destroy
@@ -271,14 +271,6 @@ module Lcms
271
271
  unit? && document_bundles.any?
272
272
  end
273
273
 
274
- def add_grade_author(author)
275
- grade = grade? ? self : ancestors.detect(&:grade?)
276
- raise 'Grade not found for this resource' unless grade
277
-
278
- grade.author_id = author.is_a?(Integer) ? author : author.id
279
- grade.save
280
- end
281
-
282
274
  def self_and_ancestors_not_persisted
283
275
  # during create we can't call self_and_ancestors directly on the resource
284
276
  # because this query uses the associations on resources_hierarchies
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Lcms
4
4
  module Engine
5
- class ResourceAdditionalResource < ActiveRecord::Base
5
+ class ResourceAdditionalResource < ApplicationRecord
6
6
  belongs_to :resource
7
7
  belongs_to :additional_resource, class_name: 'Resource', foreign_key: 'additional_resource_id'
8
8
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Lcms
4
4
  module Engine
5
- class ResourceDownload < ActiveRecord::Base
5
+ class ResourceDownload < ApplicationRecord
6
6
  DOWNLOAD_PER_CATEGORY_LIMIT = 5
7
7
 
8
8
  belongs_to :resource
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Lcms
4
4
  module Engine
5
- class ResourceReadingAssignment < ActiveRecord::Base
5
+ class ResourceReadingAssignment < ApplicationRecord
6
6
  belongs_to :reading_assignment_text
7
7
  belongs_to :resource
8
8
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Lcms
4
4
  module Engine
5
- class ResourceRelatedResource < ActiveRecord::Base
5
+ class ResourceRelatedResource < ApplicationRecord
6
6
  belongs_to :resource
7
7
  belongs_to :related_resource, class_name: 'Resource', foreign_key: 'related_resource_id'
8
8
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Lcms
4
4
  module Engine
5
- class ResourceStandard < ActiveRecord::Base
5
+ class ResourceStandard < ApplicationRecord
6
6
  belongs_to :resource
7
7
  belongs_to :standard
8
8
  end
@@ -43,7 +43,7 @@ module Lcms
43
43
  repository.search query
44
44
  end
45
45
 
46
- # this is necessary for the ActiveModel::ArraySerializer#as_json method to work
46
+ # this is necessary for the ActiveModel::Serializer::CollectionSerializer#as_json method to work
47
47
  # (used on the Pagination#serialize_with_pagination)
48
48
  # NOTE: https://github.com/rails-api/active_model_serializers/issues/891
49
49
  def read_attribute_for_serialization(key)
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Lcms
4
4
  module Engine
5
- class Settings < ActiveRecord::Base
5
+ class Settings < ApplicationRecord
6
6
  class << self
7
7
  def [](key)
8
8
  settings.data[key.to_s]
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Lcms
4
4
  module Engine
5
- class SocialThumbnail < ActiveRecord::Base
5
+ class SocialThumbnail < ApplicationRecord
6
6
  MEDIAS = %w(all facebook pinterest twitter).freeze
7
7
 
8
8
  mount_uploader :image, SocialThumbnailUploader
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Lcms
4
4
  module Engine
5
- class StaffMember < ActiveRecord::Base
5
+ class StaffMember < ApplicationRecord
6
6
  validates :first_name, :last_name, presence: true
7
7
  validates :bio, length: { maximum: 4096 }
8
8
  enum staff_type: { staff: 1, board: 2 }
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Lcms
4
4
  module Engine
5
- class Standard < ActiveRecord::Base
5
+ class Standard < ApplicationRecord
6
6
  # NOTE: #954 - to be removed?
7
7
  ALT_NAME_REGEX = {
8
8
  'ela' => /^[[:alpha:]]+\.(k|pk|\d+)\.\d+(\.[[:alnum:]]+)?$/,