diff --git a/app/controllers/api/osuny/application_controller.rb b/app/controllers/api/osuny/application_controller.rb index 0ed98e1403d0566648de9d9b966579efccc769fe..e5c8aab42cb2339ca52014fc7889770251ce4971 100644 --- a/app/controllers/api/osuny/application_controller.rb +++ b/app/controllers/api/osuny/application_controller.rb @@ -1,4 +1,5 @@ class Api::Osuny::ApplicationController < Api::ApplicationController + protected def verify_app_token @@ -6,4 +7,9 @@ class Api::Osuny::ApplicationController < Api::ApplicationController secret_key: params[:secret_key]) raise_403_unless app end + + def website + @website ||= current_university.websites.find params[:website_id] + end + end \ No newline at end of file diff --git a/app/controllers/api/osuny/communication/websites/posts_controller.rb b/app/controllers/api/osuny/communication/websites/posts_controller.rb index 4f617e3ac58c96596fe00c9a0163ea1b7e007535..785795440556f2fed0b20bc2e58a0b356c8536f7 100644 --- a/app/controllers/api/osuny/communication/websites/posts_controller.rb +++ b/app/controllers/api/osuny/communication/websites/posts_controller.rb @@ -5,6 +5,7 @@ class Api::Osuny::Communication::Websites::PostsController < Api::Osuny::Applica verify_app_token create_post import_blocks + import_categories render json: :ok end @@ -16,16 +17,6 @@ class Api::Osuny::Communication::Websites::PostsController < Api::Osuny::Applica post.save end - def post - @post ||= website.posts - .where( - university: current_university, - website: website, - migration_identifier: migration_identifier - ) - .first_or_initialize - end - def import_blocks blocks.each do |b| migration_identifier = b[:migration_identifier] @@ -43,13 +34,29 @@ class Api::Osuny::Communication::Websites::PostsController < Api::Osuny::Applica end end + def import_categories + categories.each do |category| + byebug + end + end + + def post + @post ||= website.posts.where( + university: current_university, + website: website, + migration_identifier: migration_identifier + ) + .first_or_initialize + end + def blocks return [] unless params[:post].has_key?(:blocks) @blocks ||= params[:post][:blocks] end - def website - @website ||= current_university.websites.find params[:website_id] + def categories + return [] unless params[:post].has_key?(:categories) + @categories ||= params[:post][:categories] end def migration_identifier