Remove Ransack from Exercise edit for tags
* Also improve Ransack usage of attributes and associations
This commit is contained in:
@ -461,8 +461,7 @@ class ExercisesController < ApplicationController
|
||||
private :set_file_types
|
||||
|
||||
def collect_set_and_unset_exercise_tags
|
||||
@search = policy_scope(Tag).ransack(params[:q])
|
||||
@tags = @search.result.order(:name)
|
||||
@tags = policy_scope(Tag)
|
||||
checked_exercise_tags = @exercise.exercise_tags
|
||||
checked_tags = checked_exercise_tags.collect(&:tag).to_set
|
||||
unchecked_tags = Tag.all.to_set.subtract checked_tags
|
||||
|
@ -15,4 +15,12 @@ class ApplicationRecord < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.ransackable_associations(_auth_object = nil)
|
||||
[]
|
||||
end
|
||||
|
||||
def self.ransackable_attributes(_auth_object = nil)
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
@ -61,6 +61,10 @@ class ExecutionEnvironment < ApplicationRecord
|
||||
exposed_ports.join(', ')
|
||||
end
|
||||
|
||||
def self.ransackable_attributes(_auth_object = nil)
|
||||
%w[id]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_default_values
|
||||
|
@ -597,4 +597,12 @@ cause: %w[submit assess remoteSubmit remoteAssess]}).distinct
|
||||
WHERE exercise_id = #{id}
|
||||
) AS t ON t.fv = submissions.id").distinct
|
||||
end
|
||||
|
||||
def self.ransackable_attributes(_auth_object = nil)
|
||||
%w[title]
|
||||
end
|
||||
|
||||
def self.ransackable_associations(_auth_object = nil)
|
||||
%w[execution_environment]
|
||||
end
|
||||
end
|
||||
|
@ -31,4 +31,8 @@ working_time: time_to_f(item.exercise.average_working_time)}
|
||||
def to_s
|
||||
"#{I18n.t('activerecord.models.exercise_collection.one')}: #{name} (#{id})"
|
||||
end
|
||||
|
||||
def self.ransackable_attributes(_auth_object = nil)
|
||||
%w[id]
|
||||
end
|
||||
end
|
||||
|
@ -246,4 +246,8 @@ class ProxyExercise < ApplicationRecord
|
||||
def select_easiest_exercise(exercises)
|
||||
exercises.order(:expected_difficulty).first
|
||||
end
|
||||
|
||||
def self.ransackable_attributes(_auth_object = nil)
|
||||
%w[title]
|
||||
end
|
||||
end
|
||||
|
@ -77,6 +77,14 @@ class RequestForComment < ApplicationRecord
|
||||
# ugly, but necessary
|
||||
end
|
||||
|
||||
def ransackable_associations(_auth_object = nil)
|
||||
%w[exercise submission]
|
||||
end
|
||||
|
||||
def ransackable_attributes(_auth_object = nil)
|
||||
%w[solved]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def row_number_user_sql
|
||||
|
@ -191,6 +191,10 @@ class Submission < ApplicationRecord
|
||||
result.merge(output)
|
||||
end
|
||||
|
||||
def self.ransackable_attributes(_auth_object = nil)
|
||||
%w[study_group_id]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def prepared_runner
|
||||
|
@ -41,4 +41,8 @@ class User < ApplicationRecord
|
||||
def to_s
|
||||
displayname
|
||||
end
|
||||
|
||||
def self.ransackable_attributes(_auth_object = nil)
|
||||
%w[name email external_id consumer_id role]
|
||||
end
|
||||
end
|
||||
|
@ -69,7 +69,7 @@
|
||||
thead
|
||||
tr
|
||||
th = t('activerecord.attributes.exercise.selection')
|
||||
th = sort_link(@search, :title, t('activerecord.attributes.tag.name'))
|
||||
th = t('activerecord.attributes.tag.name')
|
||||
th = t('activerecord.attributes.tag.difficulty')
|
||||
= collection_check_boxes :exercise, :tag_ids, @exercise_tags, :tag_id, :id do |b|
|
||||
tr
|
||||
|
Reference in New Issue
Block a user