X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/3204b60e04bf8613858bfc4a753d7114f6ca90a3..5b5c9a43929d392f32f7a4db1393df2dd106cbeb:/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 7e45ad779a..f5be0e1edc 100644 --- a/apps/workbench/app/models/arvados_base.rb +++ b/apps/workbench/app/models/arvados_base.rb @@ -167,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 } @@ -316,16 +318,31 @@ class ArvadosBase < ActiveRecord::Base false end + # can this class of object be copied into a project? + # override to false on indivudal model classes for which this should not be true + def self.copies_to_projects? + self.goes_in_projects? + end + def editable? (current_user and current_user.is_active and (current_user.is_admin or current_user.uuid == self.owner_uuid or new_record? or - (writable_by.include? current_user.uuid rescue false))) + (respond_to?(:writable_by) ? + writable_by.include?(current_user.uuid) : + (ArvadosBase.find(owner_uuid).writable_by.include? current_user.uuid rescue false)))) or false + end + + # Array of strings that are the names of attributes that can be edited + # with X-Editable. + def editable_attributes + self.class.columns.map(&:name) - + %w(created_at modified_at modified_by_user_uuid modified_by_client_uuid updated_at) end def attribute_editable?(attr, ever=nil) - if %w(created_at modified_at modified_by_user_uuid modified_by_client_uuid updated_at).include? attr.to_s + if not editable_attributes.include?(attr.to_s) false elsif not (current_user.andand.is_active) false @@ -371,7 +388,7 @@ class ArvadosBase < ActiveRecord::Base self.class.to_s.underscore end - def friendly_link_name + def friendly_link_name lookup=nil (name if self.respond_to? :name) || default_name end