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