From 0097f7a21f48f1424be6b4c3ec9043c0225c9f5a Mon Sep 17 00:00:00 2001 From: Kapil Sachdev Date: Thu, 28 Dec 2023 14:12:13 +0530 Subject: [PATCH] WEB-6625: Add free attribute to Lesson --- app/lib/parser/lesson_metadata.rb | 2 +- app/models/lesson.rb | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/lib/parser/lesson_metadata.rb b/app/lib/parser/lesson_metadata.rb index 76f8550..190bd23 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].freeze + VALID_SIMPLE_ATTRIBUTES = %i[title description_md learning_objectives_md ordinal ref free].freeze attr_accessor :lesson, :metadata diff --git a/app/models/lesson.rb b/app/models/lesson.rb index 323838c..7f5499d 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 + attr_accessor :title, :description_md, :ordinal, :ref, :segments, :learning_objectives_md, :free attr_markdown :description, source: :description_md, file: false attr_markdown :learning_objectives, source: :learning_objectives_md, file: false @@ -15,6 +15,7 @@ class Lesson def initialize(attributes = {}) super + @free ||= false @segments ||= [] end @@ -24,7 +25,7 @@ def slug # Used for serialisation def attributes - { title: nil, description: nil, learning_objectives: nil, ordinal: nil, segments: [], ref: nil }.stringify_keys + { title: nil, description: nil, learning_objectives: nil, ordinal: nil, segments: [], ref: nil, free: false }.stringify_keys end # Used for linting