Skip to content

Commit fe4d337

Browse files
committed
Method to get full title of an ELIXIR node e.g. "ELIXIR Belgium"
1 parent d083dc5 commit fe4d337

3 files changed

Lines changed: 16 additions & 0 deletions

File tree

app/models/node.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ def related_materials
6161
Material.where(id: provider_material_ids | material_ids)
6262
end
6363

64+
def full_title
65+
return title if title == 'EMBL-EBI'
66+
t = title
67+
t = 'UK' if title == 'United Kingdom'
68+
I18n.t('nodes.full_title', title: t)
69+
end
70+
6471
def self.load_from_hash(hash, verbose: false)
6572
hash["nodes"].map do |node_data|
6673
node = Node.find_or_initialize_by(name: node_data["name"])

config/locales/en.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,8 @@ en:
875875
hints:
876876
hide_child_nodes: Ticking this box will hide child nodes from the diagram until their parent node is clicked.
877877
public: Un-ticking this box will hide this workflow from anyone who isn't the creator or a collaborator.
878+
nodes:
879+
full_title: 'ELIXIR %{title}'
878880
menu:
879881
user:
880882
my_profile: 'My profile'

test/models/node_test.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@ class NodeTest < ActiveSupport::TestCase
121121
assert node.valid?
122122
end
123123

124+
test 'full title' do
125+
assert_equal 'ELIXIR Sweden', Node.new(title: 'Sweden').full_title
126+
assert_equal 'ELIXIR UK', Node.new(title: 'United Kingdom').full_title
127+
assert_equal 'EMBL-EBI', Node.new(title: 'EMBL-EBI').full_title
128+
assert_equal 'ELIXIR Westeros', nodes(:westeros).full_title
129+
end
130+
124131
private
125132

126133
def node_data_hash

0 commit comments

Comments
 (0)