Remove legacy save search endpoint

This commit is contained in:
Sebastian Serth
2023-07-28 13:18:39 +02:00
parent 401044fef8
commit 28a4b672f9
8 changed files with 4 additions and 29 deletions

View File

@ -330,8 +330,6 @@ class ExercisesController < ApplicationController
@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)
@ -385,18 +383,6 @@ class ExercisesController < ApplicationController
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
@ -414,7 +400,7 @@ class ExercisesController < ApplicationController
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?

View File

@ -1,6 +0,0 @@
# frozen_string_literal: true
class Search < ApplicationRecord
belongs_to :user, polymorphic: true
belongs_to :exercise
end

View File

@ -29,7 +29,7 @@ class ExercisePolicy < AdminOrAuthorPolicy
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?

View File

@ -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?

View File

@ -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

View File

@ -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

View File

@ -88,7 +88,6 @@ Rails.application.routes.draw do
get :implement
get :working_times
post :intervention
post :search
get :statistics
get :feedback
get :reload

View File

@ -134,7 +134,7 @@ describe ExercisePolicy do
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) }