diff --git a/app/controllers/api/osuny/communication/websites/posts_controller.rb b/app/controllers/api/osuny/communication/websites/posts_controller.rb index 218cc48da3b557e9b601bbc4acad15e9af66feb2..350d41a51f8660781d4af3467a17c937637adbde 100644 --- a/app/controllers/api/osuny/communication/websites/posts_controller.rb +++ b/app/controllers/api/osuny/communication/websites/posts_controller.rb @@ -35,8 +35,19 @@ class Api::Osuny::Communication::Websites::PostsController < Api::Osuny::Applica end def import_categories - categories.each do |category| - byebug + categories.each do |c| + data = c.to_unsafe_hash + if data.has_key? 'name' + category = website.categories.where( + university: current_university, + website: website, + name: data['name'], + language: website.default_language + ).first_or_create + end + next if category.nil? + next if category.in?(post.categories) + post.categories << category end end