diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 09ad545..f3aae15 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4 - name: Run tests run: | @@ -62,7 +62,7 @@ jobs: status: STARTING color: warning - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v4 - name: Set up QEMU uses: docker/setup-qemu-action@v3.0.0 diff --git a/app/lib/parser/content_module.rb b/app/lib/parser/content_module.rb index a9ecb9c..d30bcf7 100644 --- a/app/lib/parser/content_module.rb +++ b/app/lib/parser/content_module.rb @@ -12,7 +12,7 @@ class ContentModule professional difficulty platform language editor domains categories who_is_this_for_md module_outcomes_md covered_concepts_md git_commit_hash featured_banner_image twitter_card_image - access_personal access_team].freeze + access_personal access_team module_type].freeze attr_accessor :content_module diff --git a/app/lib/parser/lesson_metadata.rb b/app/lib/parser/lesson_metadata.rb index 190bd23..4019261 100644 --- a/app/lib/parser/lesson_metadata.rb +++ b/app/lib/parser/lesson_metadata.rb @@ -5,7 +5,7 @@ module Parser class LessonMetadata include SimpleAttributes - VALID_SIMPLE_ATTRIBUTES = %i[title description_md learning_objectives_md ordinal ref free].freeze + VALID_SIMPLE_ATTRIBUTES = %i[title description_md learning_objectives_md ordinal ref free program_shortcode].freeze attr_accessor :lesson, :metadata diff --git a/app/models/content_module.rb b/app/models/content_module.rb index f0635c6..ac15863 100644 --- a/app/models/content_module.rb +++ b/app/models/content_module.rb @@ -12,7 +12,7 @@ class ContentModule :platform, :language, :editor, :domains, :categories, :who_is_this_for_md, :module_outcomes_md, :covered_concepts_md, :authors, :lessons, :git_commit_hash, :featured_banner_image, :twitter_card_image, :root_path, :access_personal, - :access_team + :access_team, :module_type attr_markdown :who_is_this_for, source: :who_is_this_for_md, file: false attr_markdown :covered_concepts, source: :covered_concepts_md, file: false @@ -21,10 +21,11 @@ class ContentModule attr_image :featured_banner_image_url, source: :featured_banner_image, variants: %i[original w750 w225 w90] attr_image :twitter_card_image_url, source: :twitter_card_image, variants: %i[original w1800] - validates :shortcode, :version, :title, :version_description, :description_md, :domains, - :categories, presence: true + validates :shortcode, :version, :title, :version_description, :description_md, presence: true + validates_presence_of :domains, :categories, unless: -> { module_type == 'info' } validates_inclusion_of :difficulty, in: %w[beginner intermediate advanced] validates_inclusion_of :professional, :access_personal, :access_team, in: [true, false] + validates_inclusion_of :module_type, in: %w[study info] validates :lessons, length: { minimum: 1 }, allow_blank: false, lessons: true validates_each :domains do |record, attr, value| value.each do |domain| @@ -35,6 +36,7 @@ class ContentModule def initialize(attributes = {}) super @lessons ||= [] + @module_type ||= 'study' end # Used for serialisation @@ -44,7 +46,7 @@ def attributes professional: nil, difficulty: nil, platform: nil, language: nil, editor: nil, domains: [], categories: [], who_is_this_for: nil, covered_concepts: nil, outcomes: nil, authors: [], lessons: [], git_commit_hash: nil, featured_banner_image_url: [], - twitter_card_image_url: [], access_personal: nil, access_team: nil }.stringify_keys + twitter_card_image_url: [], access_personal: nil, access_team: nil, module_type: nil }.stringify_keys end # Used for linting diff --git a/app/models/lesson.rb b/app/models/lesson.rb index ce70093..48dbb26 100644 --- a/app/models/lesson.rb +++ b/app/models/lesson.rb @@ -7,7 +7,7 @@ class Lesson include Concerns::ImageAttachable include Concerns::MarkdownRenderable - attr_accessor :title, :description_md, :ordinal, :ref, :segments, :learning_objectives_md, :free + attr_accessor :title, :description_md, :ordinal, :ref, :segments, :learning_objectives_md, :free, :program_shortcode attr_markdown :description, source: :description_md, file: false attr_markdown :learning_objectives, source: :learning_objectives_md, file: false @@ -26,7 +26,7 @@ def slug # Used for serialisation def attributes - { title: nil, description: nil, learning_objectives: nil, ordinal: nil, segments: [], ref: nil, free: false }.stringify_keys + { title: nil, description: nil, learning_objectives: nil, ordinal: nil, segments: [], ref: nil, free: false, program_shortcode: nil }.stringify_keys end # Used for linting