X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/47042547e7873d63f764e85ace085a8da314afd3..51d54eb5a828cb60005c5c2d446d375b4ff8baac:/apps/workbench/app/models/arvados_base.rb diff --git a/apps/workbench/app/models/arvados_base.rb b/apps/workbench/app/models/arvados_base.rb index 3b5ac86f91..083db9133b 100644 --- a/apps/workbench/app/models/arvados_base.rb +++ b/apps/workbench/app/models/arvados_base.rb @@ -56,7 +56,7 @@ class ArvadosBase < ActiveRecord::Base end def self.columns - return @columns unless @columns.nil? + return @columns if @columns.andand.any? @columns = [] @attribute_info ||= {} schema = arvados_api_client.discovery[:schemas][self.to_s.to_sym] @@ -131,6 +131,10 @@ class ArvadosBase < ActiveRecord::Base ArvadosResourceList.new(self).limit(*args) end + def self.select(*args) + ArvadosResourceList.new(self).select(*args) + end + def self.eager(*args) ArvadosResourceList.new(self).eager(*args) end @@ -163,7 +167,9 @@ class ArvadosBase < ActiveRecord::Base def save obdata = {} self.class.columns.each do |col| - obdata[col.name.to_sym] = self.send(col.name.to_sym) + unless self.send(col.name.to_sym).nil? and !self.changed.include?(col.name) + obdata[col.name.to_sym] = self.send(col.name.to_sym) + end end obdata.delete :id postdata = { self.class.to_s.underscore => obdata } @@ -299,6 +305,11 @@ class ArvadosBase < ActiveRecord::Base self.to_s.underscore.humanize end + # Array of strings that are names of attributes that should be rendered as textile. + def textile_attributes + [] + end + def self.creatable? current_user end @@ -316,7 +327,7 @@ class ArvadosBase < ActiveRecord::Base end def attribute_editable?(attr, ever=nil) - if "created_at modified_at modified_by_user_uuid modified_by_client_uuid updated_at".index(attr.to_s) + if %w(created_at modified_at modified_by_user_uuid modified_by_client_uuid updated_at).include? attr.to_s false elsif not (current_user.andand.is_active) false