Skip to content
Snippets Groups Projects
Commit a162615b authored by Arnaud Levy's avatar Arnaud Levy
Browse files

wip

parent 9728fc23
No related branches found
No related tags found
No related merge requests found
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
......@@ -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
......
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