Skip to content
Snippets Groups Projects
Unverified Commit 19fde4f3 authored by Sébastien Gaya's avatar Sébastien Gaya
Browse files

reorder programs

parent 6001f7bf
No related branches found
No related tags found
No related merge requests found
......@@ -11,18 +11,22 @@ class Admin::Education::ProgramsController < Admin::Education::ApplicationContro
def reorder
parent_id = params[:parentId].blank? ? nil : params[:parentId]
ids = params[:ids] || []
programs = []
website_ids = []
ids.each.with_index do |id, index|
program = current_university.education_programs.find(id)
programs << program
website_ids.concat(program.list_of_websites.map(&:id))
programs.concat(program.descendents) if parent_id != program.parent_id
program.update(
parent_id: parent_id,
position: index + 1,
skip_websites_categories_callback: true
skip_github_publication: true
)
website_ids.concat(program.website_ids)
end
current_university.communication_websites.where(id: website_ids.uniq).each do |website|
website.set_programs_categories!
website_ids.uniq.each do |website_id|
github = Github.with_website current_university.communication_websites.find(website_id)
github.send_batch_to_website(programs, message: '[Program] Reorder programs.')
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment