X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/c203e53c2929c2ddf1b079ec077364f8f4d23c40..fc1d010fe970f6c78696423319c21b821e42fbf9:/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 7bc043cc9e..f19d47435a 100644 --- a/apps/workbench/app/models/arvados_base.rb +++ b/apps/workbench/app/models/arvados_base.rb @@ -139,8 +139,8 @@ class ArvadosBase < ActiveRecord::Base ArvadosResourceList.new(self).eager(*args) end - def self.all(*args) - ArvadosResourceList.new(self).all(*args) + def self.all + ArvadosResourceList.new(self) end def self.permit_attribute_params raw_params @@ -311,7 +311,7 @@ class ArvadosBase < ActiveRecord::Base end def self.creatable? - current_user + current_user.andand.is_active end def self.goes_in_projects? @@ -329,11 +329,20 @@ class ArvadosBase < ActiveRecord::Base (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 @@ -379,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