Introduce new enabled
option for CodeHarbor
* Fix tests to ensure they work independent of config option
This commit is contained in:
@ -2,10 +2,11 @@
|
||||
|
||||
class CodeharborLinksController < ApplicationController
|
||||
include CommonBehavior
|
||||
before_action :verify_codeharbor_activation
|
||||
before_action :set_codeharbor_link, only: %i[show edit update destroy]
|
||||
|
||||
def new
|
||||
base_url = CodeOcean::Config.new(:code_ocean).read[:codeharbor][:url]
|
||||
base_url = CodeOcean::Config.new(:code_ocean).read[:codeharbor][:url] || ''
|
||||
@codeharbor_link = CodeharborLink.new(push_url: base_url + '/import_exercise', check_uuid_url: base_url + '/import_uuid_check')
|
||||
authorize!
|
||||
end
|
||||
@ -36,6 +37,10 @@ class CodeharborLinksController < ApplicationController
|
||||
authorize @codeharbor_link
|
||||
end
|
||||
|
||||
def verify_codeharbor_activation
|
||||
raise Pundit::NotAuthorizedError unless policy(CodeharborLink).enabled?
|
||||
end
|
||||
|
||||
def set_codeharbor_link
|
||||
@codeharbor_link = CodeharborLink.find(params[:id])
|
||||
@codeharbor_link.user = current_user
|
||||
|
Reference in New Issue
Block a user