X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/278e6b7db6c0b09356bc71fd661c4ef7943e69ac..f00ee875d99ba65aaac178e762fbd3e35ddc5f87:/apps/workbench/app/models/user.rb diff --git a/apps/workbench/app/models/user.rb b/apps/workbench/app/models/user.rb index 782385fb0d..9c914776a2 100644 --- a/apps/workbench/app/models/user.rb +++ b/apps/workbench/app/models/user.rb @@ -6,22 +6,47 @@ class User < ArvadosBase end def self.current - res = $arvados_api_client.api self, '/current' - $arvados_api_client.unpack_api_response(res) + res = arvados_api_client.api self, '/current' + arvados_api_client.unpack_api_response(res) end def self.system - $arvados_system_user ||= begin - res = $arvados_api_client.api self, '/system' - $arvados_api_client.unpack_api_response(res) - end + @@arvados_system_user ||= begin + res = arvados_api_client.api self, '/system' + arvados_api_client.unpack_api_response(res) + end end def full_name (self.first_name || "") + " " + (self.last_name || "") end - def attribute_editable?(attr) - (not (self.uuid.andand.match(/000000000000000$/) and self.is_admin)) and super(attr) + def activate + self.private_reload(arvados_api_client.api(self.class, + "/#{self.uuid}/activate", + {})) end + + def attributes_for_display + super.reject { |k,v| %w(owner_uuid default_owner_uuid identity_url prefs).index k } + end + + def attribute_editable? attr, *args + (not (self.uuid.andand.match(/000000000000000$/) and self.is_admin)) and super + end + + def friendly_link_name + [self.first_name, self.last_name].compact.join ' ' + end + + def unsetup + self.private_reload(arvados_api_client.api(self.class, + "/#{self.uuid}/unsetup", + {})) + end + + def self.setup params + arvados_api_client.api(self, "/setup", params) + end + end