Skip to content

Commit

Permalink
Ordering the subject ids correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
inulty-dfe committed May 29, 2024
1 parent 9e96703 commit fa53e42
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def continue
def edit
authorize(provider)

return if selected_non_language_subjects_ids.include? modern_languages_subject_id.to_s
return if selected_non_language_subjects_ids.include? modern_languages_subject_id

redirect_to(
details_publish_provider_recruitment_cycle_course_path(
Expand Down Expand Up @@ -87,9 +87,7 @@ def selected_subjects(param_key)

ids = params.dig(:course, param_key)&.map(&:to_i) || []

@course.edit_course_options[edit_course_options_key].filter_map do |subject|
subject.id.to_s if ids.include?(subject.id)
end
ids.intersection(@course.edit_course_options[edit_course_options_key].map(&:id))
end

def selected_language_subjects_ids
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/publish/courses/subjects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ def update
else
@errors = @course.errors.messages

# Set attributes to populate the form
course.master_subject_id, course.subordinate_subject_id = selected_subject_ids
render :edit
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/course.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Course < ApplicationRecord

self.master_subject_id ||= sub.first&.subject&.id

self.subordinate_subject_id ||= sub&.second&.subject&.id
self.subordinate_subject_id = sub&.second&.subject&.id
end
end

Expand Down

0 comments on commit fa53e42

Please sign in to comment.