readding codeharbor_link views and actions
This commit is contained in:
@@ -1,68 +0,0 @@
|
||||
class CodeHarborLinksController < ApplicationController
|
||||
include CommonBehavior
|
||||
before_action :set_code_harbor_link, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
def authorize!
|
||||
authorize(@code_harbor_link || @code_harbor_links)
|
||||
end
|
||||
private :authorize!
|
||||
|
||||
# GET /code_harbor_links
|
||||
# GET /code_harbor_links.json
|
||||
def index
|
||||
@code_harbor_links = CodeHarborLink.where(user_id: current_user.id).paginate(page: params[:page])
|
||||
authorize!
|
||||
end
|
||||
|
||||
# GET /code_harbor_links/1
|
||||
# GET /code_harbor_links/1.json
|
||||
def show
|
||||
authorize!
|
||||
end
|
||||
|
||||
# GET /code_harbor_links/new
|
||||
def new
|
||||
@code_harbor_link = CodeHarborLink.new
|
||||
authorize!
|
||||
end
|
||||
|
||||
# GET /code_harbor_links/1/edit
|
||||
def edit
|
||||
authorize!
|
||||
end
|
||||
|
||||
# POST /code_harbor_links
|
||||
# POST /code_harbor_links.json
|
||||
def create
|
||||
@code_harbor_link = CodeHarborLink.new(code_harbor_link_params)
|
||||
@code_harbor_link.user = current_user
|
||||
authorize!
|
||||
create_and_respond(object: @code_harbor_link)
|
||||
end
|
||||
|
||||
# PATCH/PUT /code_harbor_links/1
|
||||
# PATCH/PUT /code_harbor_links/1.json
|
||||
def update
|
||||
update_and_respond(object: @code_harbor_link, params: code_harbor_link_params)
|
||||
authorize!
|
||||
end
|
||||
|
||||
# DELETE /code_harbor_links/1
|
||||
# DELETE /code_harbor_links/1.json
|
||||
def destroy
|
||||
destroy_and_respond(object: @code_harbor_link)
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_code_harbor_link
|
||||
@code_harbor_link = CodeHarborLink.find(params[:id])
|
||||
@code_harbor_link.user = current_user
|
||||
authorize!
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def code_harbor_link_params
|
||||
params.require(:code_harbor_link).permit(:oauth2token)
|
||||
end
|
||||
end
|
55
app/controllers/codeharbor_links_controller.rb
Normal file
55
app/controllers/codeharbor_links_controller.rb
Normal file
@@ -0,0 +1,55 @@
|
||||
class CodeharborLinksController < ApplicationController
|
||||
include CommonBehavior
|
||||
before_action :set_codeharbor_link, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
def authorize!
|
||||
authorize(@codeharbor_link || @codeharbor_links)
|
||||
end
|
||||
private :authorize!
|
||||
|
||||
def index
|
||||
@codeharbor_links = CodeharborLink.where(user_id: current_user.id).paginate(page: params[:page])
|
||||
authorize!
|
||||
end
|
||||
|
||||
def show
|
||||
authorize!
|
||||
end
|
||||
|
||||
def new
|
||||
@codeharbor_link = CodeharborLink.new
|
||||
authorize!
|
||||
end
|
||||
|
||||
def edit
|
||||
authorize!
|
||||
end
|
||||
|
||||
def create
|
||||
@codeharbor_link = CodeharborLink.new(codeharbor_link_params)
|
||||
@codeharbor_link.user = current_user
|
||||
authorize!
|
||||
create_and_respond(object: @codeharbor_link)
|
||||
end
|
||||
|
||||
def update
|
||||
update_and_respond(object: @codeharbor_link, params: codeharbor_link_params)
|
||||
authorize!
|
||||
end
|
||||
|
||||
def destroy
|
||||
destroy_and_respond(object: @codeharbor_link)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_codeharbor_link
|
||||
@codeharbor_link = CodeharborLink.find(params[:id])
|
||||
@codeharbor_link.user = current_user
|
||||
authorize!
|
||||
end
|
||||
|
||||
def codeharbor_link_params
|
||||
params.require(:codeharbor_link).permit(:push_url, :oauth2token, :client_id, :client_secret)
|
||||
end
|
||||
end
|
@@ -108,34 +108,17 @@ class ExercisesController < ApplicationController
|
||||
end
|
||||
|
||||
def import_proforma_xml
|
||||
# begin
|
||||
# user = user_for_oauth2_request
|
||||
# exercise = Exercise.new
|
||||
# request_body = request.body.read # needs to be some kind of a zip file
|
||||
|
||||
tempfile = Tempfile.new('codeharbor_import.zip')
|
||||
tempfile.write request.body.read.force_encoding('UTF-8')
|
||||
tempfile.rewind
|
||||
|
||||
exercise = ProformaService::Import.call(zip: tempfile, user: user_for_oauth2_request)
|
||||
# exercise.from_proforma_xml(request_body)
|
||||
# exercise.user = user
|
||||
# saved = exercise.save
|
||||
if exercise.save
|
||||
# render text: 'SUCCESS', status: 200
|
||||
render json: {}, status: 201
|
||||
else
|
||||
logger.info(exercise.errors.full_messages)
|
||||
render json: {}, status: 400
|
||||
end
|
||||
# rescue => error
|
||||
# if error.class == Hash
|
||||
# render :text => error.message, :status => error.status
|
||||
# else
|
||||
# raise error
|
||||
# render :text => '', :status => 500
|
||||
# end
|
||||
# end
|
||||
end
|
||||
|
||||
def user_for_oauth2_request
|
||||
|
Reference in New Issue
Block a user