Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WEB-6625: Add free attribute to Lesson #235

Merged
merged 1 commit into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/lib/parser/lesson_metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions app/models/lesson.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ 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
validates :title, :ordinal, :ref, presence: true

def initialize(attributes = {})
super
@free ||= false
@segments ||= []
end

Expand All @@ -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
Expand Down