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 class Api::Osuny::ApplicationController < Api::ApplicationController
protected protected
def verify_app_token def verify_app_token
...@@ -6,4 +7,9 @@ class Api::Osuny::ApplicationController < Api::ApplicationController ...@@ -6,4 +7,9 @@ class Api::Osuny::ApplicationController < Api::ApplicationController
secret_key: params[:secret_key]) secret_key: params[:secret_key])
raise_403_unless app raise_403_unless app
end end
def website
@website ||= current_university.websites.find params[:website_id]
end
end end
\ No newline at end of file
...@@ -5,6 +5,7 @@ class Api::Osuny::Communication::Websites::PostsController < Api::Osuny::Applica ...@@ -5,6 +5,7 @@ class Api::Osuny::Communication::Websites::PostsController < Api::Osuny::Applica
verify_app_token verify_app_token
create_post create_post
import_blocks import_blocks
import_categories
render json: :ok render json: :ok
end end
...@@ -16,16 +17,6 @@ class Api::Osuny::Communication::Websites::PostsController < Api::Osuny::Applica ...@@ -16,16 +17,6 @@ class Api::Osuny::Communication::Websites::PostsController < Api::Osuny::Applica
post.save post.save
end end
def post
@post ||= website.posts
.where(
university: current_university,
website: website,
migration_identifier: migration_identifier
)
.first_or_initialize
end
def import_blocks def import_blocks
blocks.each do |b| blocks.each do |b|
migration_identifier = b[:migration_identifier] migration_identifier = b[:migration_identifier]
...@@ -43,13 +34,29 @@ class Api::Osuny::Communication::Websites::PostsController < Api::Osuny::Applica ...@@ -43,13 +34,29 @@ class Api::Osuny::Communication::Websites::PostsController < Api::Osuny::Applica
end end
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 def blocks
return [] unless params[:post].has_key?(:blocks) return [] unless params[:post].has_key?(:blocks)
@blocks ||= params[:post][:blocks] @blocks ||= params[:post][:blocks]
end end
def website def categories
@website ||= current_university.websites.find params[:website_id] return [] unless params[:post].has_key?(:categories)
@categories ||= params[:post][:categories]
end end
def migration_identifier 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