projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge remote-tracking branch 'origin/master' into 2035-arv-mount-tags-folders
[arvados.git]
/
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 4b5a27d99621d4d25e4c66fcb30581fadace4186..30027c8c78c9db764bb1744541cb5bfd563bcf05 100644
(file)
--- a/
services/api/app/controllers/application_controller.rb
+++ b/
services/api/app/controllers/application_controller.rb
@@
-1,3
+1,16
@@
+module ApiTemplateOverride
+ def allowed_to_render?(fieldset, field, model, options)
+ if options[:select]
+ return options[:select].include? field.to_s
+ end
+ super
+ end
+end
+
+class ActsAsApi::ApiTemplate
+ prepend ApiTemplateOverride
+end
+
require 'load_param'
require 'record_filters'
require 'load_param'
require 'record_filters'
@@
-9,6
+22,7
@@
class ApplicationController < ActionController::Base
ERROR_ACTIONS = [:render_error, :render_not_found]
ERROR_ACTIONS = [:render_error, :render_not_found]
+
respond_to :json
protect_from_forgery
respond_to :json
protect_from_forgery
@@
-33,7
+47,7
@@
class ApplicationController < ActionController::Base
attr_accessor :resource_attrs
def index
attr_accessor :resource_attrs
def index
- @objects.uniq!(&:id)
+ @objects.uniq!(&:id)
if @select.nil? or @select.include? "id"
if params[:eager] and params[:eager] != '0' and params[:eager] != 0 and params[:eager] != ''
@objects.each(&:eager_load_associations)
end
if params[:eager] and params[:eager] != '0' and params[:eager] != 0 and params[:eager] != ''
@objects.each(&:eager_load_associations)
end
@@
-246,6
+260,8
@@
class ApplicationController < ActionController::Base
end
end
end
end
+ @objects = @objects.select(@select.map { |s| "#{table_name}.#{ActiveRecord::Base.connection.quote_column_name s.to_s}" }.join ", ") if @select
+ @objects = @objects.uniq(ActiveRecord::Base.connection.quote_column_name @distinct.to_s) if @distinct
@objects = @objects.order(@orders.join ", ") if @orders.any?
@objects = @objects.limit(@limit)
@objects = @objects.offset(@offset)
@objects = @objects.order(@orders.join ", ") if @orders.any?
@objects = @objects.limit(@limit)
@objects = @objects.offset(@offset)
@@
-403,7
+419,7
@@
class ApplicationController < ActionController::Base
:self_link => "",
:offset => @offset,
:limit => @limit,
:self_link => "",
:offset => @offset,
:limit => @limit,
- :items => @objects.as_api_response(nil)
+ :items => @objects.as_api_response(nil
, {select: @select}
)
}
if @objects.respond_to? :except
@object_list[:items_available] = @objects.
}
if @objects.respond_to? :except
@object_list[:items_available] = @objects.