Skip to content

Commit

Permalink
Remove legacy save search endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
MrSerth committed Jul 28, 2023
1 parent 401044f commit 28a4b67
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 29 deletions.
16 changes: 1 addition & 15 deletions app/controllers/exercises_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,6 @@ def implement

@hide_rfc_button = @embed_options[:disable_rfc]

@search = Search.new
@search.exercise = @exercise
@submission = current_user.submissions.where(exercise_id: @exercise.id).order('created_at DESC').first
@files = (@submission ? @submission.collect_files : @exercise.files).select(&:visible).sort_by(&:filepath)
@paths = collect_paths(@files)
Expand Down Expand Up @@ -385,18 +383,6 @@ def intervention
end
end

def search
search_text = params[:search_text]
search = Search.new(user: current_user, exercise: @exercise, search: search_text)

begin
search.save
render(json: {success: 'true'})
rescue StandardError
render(json: {success: 'false', error: "could not save search: #{$ERROR_INFO}"})
end
end

def edit; end

def create
Expand All @@ -414,7 +400,7 @@ def create

def not_authorized_for_exercise(_exception)
return render_not_authorized unless current_user
return render_not_authorized unless %w[implement working_times intervention search reload].include?(action_name)
return render_not_authorized unless %w[implement working_times intervention reload].include?(action_name)

if current_user.admin? || current_user.teacher?
redirect_to(@exercise, alert: t('exercises.implement.unpublished')) if @exercise.unpublished?
Expand Down
6 changes: 0 additions & 6 deletions app/models/search.rb

This file was deleted.

2 changes: 1 addition & 1 deletion app/policies/exercise_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def detailed_statistics?
define_method(action) { (admin? || teacher_in_study_group? || author?) && @user.codeharbor_link }
end

%i[implement? working_times? intervention? search? reload?].each do |action|
%i[implement? working_times? intervention? reload?].each do |action|
define_method(action) do
return no_one unless @record.files.any? {|f| f.hidden == false } && @record.execution_environment.present?

Expand Down
2 changes: 1 addition & 1 deletion app/views/exercises/_editor.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- show_tips_interventions = @show_tips_interventions || "false"
- hide_rfc_button = @hide_rfc_button || false

#editor.row data-exercise-id=@exercise.id data-message-depleted=t('exercises.editor.depleted') data-message-timeout=t('exercises.editor.timeout', permitted_execution_time: @exercise.execution_environment.permitted_execution_time) data-message-out-of-memory=t('exercises.editor.out_of_memory', memory_limit: @exercise.execution_environment.memory_limit) data-submissions-url=submissions_path data-user-id=current_user.id data-user-external-id=external_user_external_id data-working-times-url=working_times_exercise_path(@exercise) data-intervention-save-url=intervention_exercise_path(@exercise) data-rfc-interventions=show_rfc_interventions data-break-interventions=show_break_interventions data-tips-interventions=show_tips_interventions data-search-save-url=search_exercise_path(@exercise)
#editor.row data-exercise-id=@exercise.id data-message-depleted=t('exercises.editor.depleted') data-message-timeout=t('exercises.editor.timeout', permitted_execution_time: @exercise.execution_environment.permitted_execution_time) data-message-out-of-memory=t('exercises.editor.out_of_memory', memory_limit: @exercise.execution_environment.memory_limit) data-submissions-url=submissions_path data-user-id=current_user.id data-user-external-id=external_user_external_id data-working-times-url=working_times_exercise_path(@exercise) data-intervention-save-url=intervention_exercise_path(@exercise) data-rfc-interventions=show_rfc_interventions data-break-interventions=show_break_interventions data-tips-interventions=show_tips_interventions
- unless @embed_options[:hide_sidebar]
- additional_classes = 'sidebar-col'
- if @tips.blank?
Expand Down
2 changes: 0 additions & 2 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -617,8 +617,6 @@ de:
form:
study_groups: Lerngruppen
click_to_collapse: Zum Aus-/Einklappen hier klicken...
search:
search_in_forum: "Probleme? Suche hier im Forum"
locales:
de: Deutsch
en: Englisch
Expand Down
2 changes: 0 additions & 2 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -617,8 +617,6 @@ en:
success: You successfully changed your password.
show:
link: Profile
search:
search_in_forum: "Problems? Search here in forum"
locales:
de: German
en: English
Expand Down
1 change: 0 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
get :implement
get :working_times
post :intervention
post :search
get :statistics
get :feedback
get :reload
Expand Down
2 changes: 1 addition & 1 deletion spec/policies/exercise_policy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
end
end

%i[implement? working_times? intervention? search? reload?].each do |action|
%i[implement? working_times? intervention? reload?].each do |action|
permissions(action) do
context 'when the exercise has no visible files' do
let(:exercise) { create(:dummy) }
Expand Down

0 comments on commit 28a4b67

Please sign in to comment.