Forked from
PortalMEC / portalmec
623 commits behind the upstream repository.
-
Marcela Ribeiro de Oliveira authoredMarcela Ribeiro de Oliveira authored
publishes_controller.rb 774 B
class V1::LearningObjects::PublishesController < ApplicationController
before_action :set_learning_object
before_action :authorize!
# POST /learning_objects/:id/publish
def create
return render status: :ok if @learning_object.published?
publisher = LearningObjectPublisher.new(DspaceService.create_client)
publisher.publish @learning_object
render status: :ok
end
private
# Use callbacks to share common setup or constraints between actions.
def set_learning_object
@learning_object = LearningObject.find(params[:id])
end
def authorize!
authorize(@learning_object, :publish?)
end
# Never trust parameters from the scary internet, only allow the white list through.
def publish_params
params.permit(:id)
end
end