projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Job reuse bugfix: do not reuse completed jobs that have NULL output.
[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 979e2d1bfe2117741e74dc8b833831736c18f6f0..4b13fca1de45757292592e80152700efe8c83954 100644
(file)
--- a/
services/api/app/controllers/application_controller.rb
+++ b/
services/api/app/controllers/application_controller.rb
@@
-1,5
+1,6
@@
class ApplicationController < ActionController::Base
include CurrentApiClient
class ApplicationController < ActionController::Base
include CurrentApiClient
+ include ThemesForRails::ActionController
respond_to :json
protect_from_forgery
respond_to :json
protect_from_forgery
@@
-20,6
+21,8
@@
class ApplicationController < ActionController::Base
:render_error,
:render_not_found]
:render_error,
:render_not_found]
+ theme :select_theme
+
attr_accessor :resource_attrs
def index
attr_accessor :resource_attrs
def index
@@
-118,12
+121,14
@@
class ApplicationController < ActionController::Base
end
def load_filters_param
end
def load_filters_param
+ @filters ||= []
if params[:filters].is_a? Array
if params[:filters].is_a? Array
- @filters = params[:filters]
- elsif params[:filters].is_a? String
+ @filters
+
= params[:filters]
+ elsif params[:filters].is_a? String
and !params[:filters].empty?
begin
begin
- @filters = Oj.load params[:filters]
- raise unless @filters.is_a? Array
+ f = Oj.load params[:filters]
+ raise unless f.is_a? Array
+ @filters += f
rescue
raise ArgumentError.new("Could not parse \"filters\" param as an array")
end
rescue
raise ArgumentError.new("Could not parse \"filters\" param as an array")
end
@@
-140,7
+145,7
@@
class ApplicationController < ActionController::Base
cond_out = []
param_out = []
@filters.each do |attr, operator, operand|
cond_out = []
param_out = []
@filters.each do |attr, operator, operand|
- if !model_class.searchable_columns.index attr.to_s
+ if !model_class.searchable_columns
(operator)
.index attr.to_s
raise ArgumentError.new("Invalid attribute '#{attr}' in condition")
end
case operator.downcase
raise ArgumentError.new("Invalid attribute '#{attr}' in condition")
end
case operator.downcase
@@
-164,16
+169,13
@@
class ApplicationController < ActionController::Base
operand = [operand] unless operand.is_a? Array
cond = []
operand.each do |op|
operand = [operand] unless operand.is_a? Array
cond = []
operand.each do |op|
- m = op.match /arvados#(.+)/
- begin
- cl = m[1].classify.andand.constantize if m
+ cl = ArvadosModel::kind_class op
if cl
cond << "#{table_name}.#{attr} like ?"
if cl
cond << "#{table_name}.#{attr} like ?"
- param_out << "_____-#{cl.uuid_prefix}-_______________"
+ param_out << cl.uuid_like_pattern
+ else
+ cond << "1=0"
end
end
- rescue NameError
- cond << "1=0"
- end
end
cond_out << cond.join(' OR ')
end
end
cond_out << cond.join(' OR ')
end
@@
-185,13
+187,12
@@
class ApplicationController < ActionController::Base
if @where.is_a? Hash and @where.any?
conditions = ['1=1']
@where.each do |attr,value|
if @where.is_a? Hash and @where.any?
conditions = ['1=1']
@where.each do |attr,value|
- if attr
== :any
+ if attr
.to_s == 'any'
if value.is_a?(Array) and
value.length == 2 and
if value.is_a?(Array) and
value.length == 2 and
- value[0] == 'contains' and
- model_class.columns.collect(&:name).index('name') then
+ value[0] == 'contains' then
ilikes = []
ilikes = []
- model_class.searchable_columns.each do |column|
+ model_class.searchable_columns
('ilike')
.each do |column|
ilikes << "#{table_name}.#{column} ilike ?"
conditions << "%#{value[1]}%"
end
ilikes << "#{table_name}.#{column} ilike ?"
conditions << "%#{value[1]}%"
end
@@
-255,7
+256,7
@@
class ApplicationController < ActionController::Base
end
else
@offset = 0
end
else
@offset = 0
- end
+ end
orders = []
if params[:order]
orders = []
if params[:order]
@@
-351,6
+352,9
@@
class ApplicationController < ActionController::Base
session[:api_client_authorization_id] = api_client_auth.id
user = api_client_auth.user
api_client = api_client_auth.api_client
session[:api_client_authorization_id] = api_client_auth.id
user = api_client_auth.user
api_client = api_client_auth.api_client
+ else
+ # Token seems valid, but points to a non-existent (deleted?) user.
+ api_client_auth = nil
end
elsif session[:user_id]
user = User.find(session[:user_id]) rescue nil
end
elsif session[:user_id]
user = User.find(session[:user_id]) rescue nil
@@
-444,7
+448,9
@@
class ApplicationController < ActionController::Base
:items => @objects.as_api_response(nil)
}
if @objects.respond_to? :except
:items => @objects.as_api_response(nil)
}
if @objects.respond_to? :except
- @object_list[:items_available] = @objects.except(:limit).except(:offset).count
+ @object_list[:items_available] = @objects.
+ except(:limit).except(:offset).
+ count(:id, distinct: true)
end
render json: @object_list
end
end
render json: @object_list
end
@@
-467,7
+473,7
@@
class ApplicationController < ActionController::Base
order: { type: 'string', required: false }
}
end
order: { type: 'string', required: false }
}
end
-
+
def client_accepts_plain_text_stream
(request.headers['Accept'].split(' ') &
['text/plain', '*/*']).count > 0
def client_accepts_plain_text_stream
(request.headers['Accept'].split(' ') &
['text/plain', '*/*']).count > 0
@@
-486,4
+492,8
@@
class ApplicationController < ActionController::Base
end
super *opts
end
end
super *opts
end
+
+ def select_theme
+ return Rails.configuration.arvados_theme
+ end
end
end