Deny /implement without execution environment

Also, fix a smaller typo in the locales
This commit is contained in:
Sebastian Serth
2023-01-20 23:53:08 +01:00
parent 2679f5fa56
commit 234a4fe02b
4 changed files with 5 additions and 2 deletions

View File

@@ -443,6 +443,7 @@ class ExercisesController < ApplicationController
if current_user.admin? || current_user.teacher?
redirect_to(@exercise, alert: t('exercises.implement.unpublished')) if @exercise.unpublished?
redirect_to(@exercise, alert: t('exercises.implement.no_files')) unless @exercise.files.visible.exists?
redirect_to(@exercise, alert: t('exercises.implement.no_execution_environment')) if @exercise.execution_environment.blank?
else
render_not_authorized
end

View File

@@ -31,7 +31,7 @@ class ExercisePolicy < AdminOrAuthorPolicy
%i[implement? working_times? intervention? search? reload?].each do |action|
define_method(action) do
return no_one unless @record.files.visible.exists?
return no_one unless @record.files.visible.exists? && @record.execution_environment.present?
admin? || teacher_in_study_group? || author? || (everyone && !@record.unpublished?)
end