From aa8870b8c85e2edcf67148cecb551e40611cb9e7 Mon Sep 17 00:00:00 2001 From: "leo.selig" Date: Thu, 4 Feb 2016 09:28:50 +0100 Subject: [PATCH] Add endpoint for import (leoselig/codeocean#1) - currently route is still named /thin_common_cartridge - points to exercise controller for simplicity (open for discussion) --- app/controllers/exercises_controller.rb | 10 ++++++++++ config/routes.rb | 2 ++ 2 files changed, 12 insertions(+) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 4f5e5b81..ec675de9 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -11,6 +11,10 @@ class ExercisesController < ApplicationController before_action :set_file_types, only: [:create, :edit, :new, :update] before_action :set_teams, only: [:create, :edit, :new, :update] + skip_before_filter :verify_authenticity_token, only: [:import_thin_common_cartridge] + skip_after_action :verify_authorized, only: [:import_thin_common_cartridge] + skip_after_action :verify_policy_scoped, only: [:import_thin_common_cartridge] + def authorize! authorize(@exercise || @exercises) end @@ -62,6 +66,12 @@ class ExercisesController < ApplicationController def edit end + def import_thin_common_cartridge + logger.info(request.headers['Authorization']) + logger.info(request.headers['Authorisation']) + render :nothing => true, :status => 200, :content_type => 'text/html' + end + def exercise_params params[:exercise].permit(:description, :execution_environment_id, :file_id, :instructions, :public, :hide_file_tree, :team_id, :title, files_attributes: file_attributes).merge(user_id: current_user.id, user_type: current_user.class.name) end diff --git a/config/routes.rb b/config/routes.rb index 24f6a0d9..af5dfdaa 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -40,6 +40,8 @@ Rails.application.routes.draw do resources :hints end + post '/thin_common_cartridge' => 'exercises#import_thin_common_cartridge' + resources :exercises do collection do match '', to: 'exercises#batch_update', via: [:patch, :put]