[ARVADOS] updated: 5225a4deab9bf526d4e178cb5220f790b3d33e67
git at public.curoverse.com
git at public.curoverse.com
Tue Jan 14 17:44:53 EST 2014
Summary of changes:
apps/workbench/app/helpers/application_helper.rb | 21 ++++++++++++---------
apps/workbench/app/models/arvados_base.rb | 6 ++++++
apps/workbench/app/models/node.rb | 3 +++
apps/workbench/app/models/user.rb | 4 ++++
apps/workbench/app/models/virtual_machine.rb | 3 +++
5 files changed, 28 insertions(+), 9 deletions(-)
via 5225a4deab9bf526d4e178cb5220f790b3d33e67 (commit)
from e049bc7067a800c2852ffaf82c9b530cef5b9f19 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 5225a4deab9bf526d4e178cb5220f790b3d33e67
Author: Tom Clegg <tom at curoverse.com>
Date: Tue Jan 14 14:41:54 2014 -0800
If a GET fails while looking up a friendly name, skip the hyperlink
instead of crashing.
Also, move the "choose a friendly name" logic from helper to model.
refs #1871
diff --git a/apps/workbench/app/helpers/application_helper.rb b/apps/workbench/app/helpers/application_helper.rb
index 4b34886..5500938 100644
--- a/apps/workbench/app/helpers/application_helper.rb
+++ b/apps/workbench/app/helpers/application_helper.rb
@@ -54,17 +54,20 @@ module ApplicationHelper
if !link_name
link_name = link_uuid
- if opts[:friendly_name] and resource_class.column_names.include? "name" and resource_class.find(link_uuid).name != nil and not resource_class.find(link_uuid).name.empty?
- link_name = "#{resource_class.to_s} #{resource_class.find(link_uuid).name}"
- elsif opts[:friendly_name] and resource_class.column_names.include? "hostname" and resource_class.find(link_uuid).hostname != nil and not resource_class.find(link_uuid).hostname.empty?
- link_name = "#{resource_class.to_s} #{resource_class.find(link_uuid).hostname}"
- elsif opts[:friendly_name] and resource_class.column_names.include? "first_name"
- link_name = "#{resource_class.to_s} #{resource_class.find(link_uuid).first_name} #{resource_class.find(link_uuid).last_name}"
- else
- if opts[:with_class_name]
- link_name = "#{resource_class.to_s} #{link_name}"
+ if opts[:friendly_name]
+ begin
+ friendly_name = resource_class.find(link_uuid).friendly_link_name
+ if friendly_name and not friendly_name.empty?
+ link_name = friendly_name
+ end
+ rescue RuntimeError
+ # If that lookup failed, the link will too. So don't make one.
+ return attrvalue
end
end
+ if opts[:with_class_name]
+ link_name = "#{resource_class.to_s}: #{link_name}"
+ end
end
link_to link_name, { controller: resource_class.to_s.underscore.pluralize, action: 'show', id: link_uuid }, style_opts
else
diff --git a/apps/workbench/app/models/arvados_base.rb b/apps/workbench/app/models/arvados_base.rb
index 83588f0..a648a8f 100644
--- a/apps/workbench/app/models/arvados_base.rb
+++ b/apps/workbench/app/models/arvados_base.rb
@@ -260,6 +260,12 @@ class ArvadosBase < ActiveRecord::Base
resource_class
end
+ def friendly_link_name
+ if self.class.column_names.include? 'name'
+ self.name
+ end
+ end
+
protected
def forget_uuid!
diff --git a/apps/workbench/app/models/node.rb b/apps/workbench/app/models/node.rb
index e67dd9e..048ac59 100644
--- a/apps/workbench/app/models/node.rb
+++ b/apps/workbench/app/models/node.rb
@@ -1,3 +1,6 @@
class Node < ArvadosBase
attr_accessor :object
+ def friendly_link_name
+ self.hostname
+ end
end
diff --git a/apps/workbench/app/models/user.rb b/apps/workbench/app/models/user.rb
index bc1f476..7ab532d 100644
--- a/apps/workbench/app/models/user.rb
+++ b/apps/workbench/app/models/user.rb
@@ -30,4 +30,8 @@ class User < ArvadosBase
def attribute_editable?(attr)
(not (self.uuid.andand.match(/000000000000000$/) and self.is_admin)) and super(attr)
end
+
+ def friendly_link_name
+ [self.first_name, self.last_name].compact.join ' '
+ end
end
diff --git a/apps/workbench/app/models/virtual_machine.rb b/apps/workbench/app/models/virtual_machine.rb
index 1b67210..5f6131e 100644
--- a/apps/workbench/app/models/virtual_machine.rb
+++ b/apps/workbench/app/models/virtual_machine.rb
@@ -15,4 +15,7 @@ class VirtualMachine < ArvadosBase
{current_user_logins: {column_heading: "logins", type: 'array'}},
super]
end
+ def friendly_link_name
+ self.hostname
+ end
end
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list