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-6880: Adding module_type and program_shortcode to module + lesson #252

Merged
merged 3 commits into from
Mar 13, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4.1.1
- uses: actions/checkout@v4

- name: Run tests
run: |
Expand Down Expand Up @@ -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/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion app/lib/parser/content_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
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 free].freeze
VALID_SIMPLE_ATTRIBUTES = %i[title description_md learning_objectives_md ordinal ref free program_shortcode].freeze

attr_accessor :lesson, :metadata

Expand Down
10 changes: 6 additions & 4 deletions app/models/content_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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|
Expand All @@ -35,6 +36,7 @@ class ContentModule
def initialize(attributes = {})
super
@lessons ||= []
@module_type ||= 'study'
end

# Used for serialisation
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/models/lesson.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down