X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/6c564c9ce38a31df9f14e1988f4065c4854516d8..dcb6eaa5012bf1eea607c61209bee18723769c24:/services/api/app/controllers/application_controller.rb diff --git a/services/api/app/controllers/application_controller.rb b/services/api/app/controllers/application_controller.rb index 89bda3cdee..3c5bf94d2c 100644 --- a/services/api/app/controllers/application_controller.rb +++ b/services/api/app/controllers/application_controller.rb @@ -14,13 +14,11 @@ class ActsAsApi::ApiTemplate end require 'load_param' -require 'record_filters' class ApplicationController < ActionController::Base include CurrentApiClient include ThemesForRails::ActionController include LoadParam - include RecordFilters respond_to :json protect_from_forgery @@ -207,11 +205,7 @@ class ApplicationController < ActionController::Base def apply_filters model_class=nil model_class ||= self.model_class - ft = record_filters @filters, model_class - if ft[:cond_out].any? - @objects = @objects.where('(' + ft[:cond_out].join(') AND (') + ')', - *ft[:param_out]) - end + @objects = model_class.apply_filters(@objects, @filters) end def apply_where_limit_order_params model_class=nil @@ -277,21 +271,6 @@ class ApplicationController < ActionController::Base # Map attribute names in @select to real column names, resolve # those to fully-qualified SQL column names, and pass the # resulting string to the select method. - if @select.empty? - raise ArgumentError.new("Attribute selection list cannot be empty") - end - api_column_map = model_class.attributes_required_columns - invalid_attrs = [] - @select.each do |s| - next if ["href", "kind", "etag"].include? s - if not s.is_a? String - raise ArgumentError.new("Attribute '#{s}' should be a string") - end - invalid_attrs.append(s) if not api_column_map.include? s - end - if not invalid_attrs.empty? - raise ArgumentError.new("Invalid attribute(s): '#{invalid_attrs.join(', ')}'") - end columns_list = model_class.columns_for_attributes(@select). map { |s| "#{ar_table_name}.#{ActiveRecord::Base.connection.quote_column_name s}" } @objects = @objects.select(columns_list.join(", "))