add functionality, when user is not authorized
This commit is contained in:
@ -120,12 +120,16 @@ class ExercisesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def import_uuid_check
|
def import_uuid_check
|
||||||
|
user = user_for_oauth2_request
|
||||||
|
return render json: {}, status: 401 if user.nil?
|
||||||
|
|
||||||
uuid = params[:uuid]
|
uuid = params[:uuid]
|
||||||
exercise = Exercise.find_by(uuid: uuid)
|
exercise = Exercise.find_by(uuid: uuid)
|
||||||
|
|
||||||
return render json: {exercise_found: false, message: t('exercises.import_codeharbor.check.no_exercise')} if exercise.nil?
|
return render json: {exercise_found: false, message: t('exercises.import_codeharbor.check.no_exercise')} if exercise.nil?
|
||||||
|
return render json: {exercise_found: true, update_right: false, message: t('exercises.import_codeharbor.check.exercise_found_no_right')} unless ExercisePolicy.new(user, exercise).update?
|
||||||
|
|
||||||
render json: {exercise_found: true, message: t('exercises.import_codeharbor.check.exercise_found')}
|
render json: {exercise_found: true, update_right: true, message: t('exercises.import_codeharbor.check.exercise_found')}
|
||||||
end
|
end
|
||||||
|
|
||||||
def import_proforma_xml
|
def import_proforma_xml
|
||||||
|
@ -320,7 +320,8 @@ en:
|
|||||||
import_codeharbor:
|
import_codeharbor:
|
||||||
check:
|
check:
|
||||||
no_exercise: No corresponding exercise found on Codeocean. Pushing this exercise will create a new one on Codeocean, which will be linked to this one on Codeharbor, any changes to either one can be pushed to the respective other platform.
|
no_exercise: No corresponding exercise found on Codeocean. Pushing this exercise will create a new one on Codeocean, which will be linked to this one on Codeharbor, any changes to either one can be pushed to the respective other platform.
|
||||||
exercise_found: A corresponding exercise has been found on Codeocean. You can either <ul><li>Create a new exercise as a duplicate of this one Codeharbor and push it to Codeocean, using the "Create new" button.</li><li>Overwrite the exercise on Codeocean, by pushing all changes. Only use "Overwrite" for bugfixes or very small changes - it will alter and may break published exercises.</li></ul>
|
exercise_found: A corresponding exercise has been found on Codeocean. You can either <ul><li>Create a new exercise as a duplicate of this one on Codeharbor and push it to Codeocean, using the "Create new" button.</li><li>Overwrite the exercise on Codeocean, by pushing all changes. Only use "Overwrite" for bugfixes or very small changes - it will alter and may break published exercises.</li></ul>
|
||||||
|
exercise_found_no_right: A corresponding exercise has been found on Codeocean, but you don't have the rights to edit it. You can only <ul><li>Create a new exercise as a duplicate of this one on Codeharbor and push it to Codeocean, using the "Create new" button.</li></ul>
|
||||||
export_codeharbor:
|
export_codeharbor:
|
||||||
fail: Failed to push the exercise to CodeHarbor.
|
fail: Failed to push the exercise to CodeHarbor.
|
||||||
label: Export to Codeharbor
|
label: Export to Codeharbor
|
||||||
|
Reference in New Issue
Block a user