From 7d352075797cd97786e9a8d65cfe4d5938ef8f28 Mon Sep 17 00:00:00 2001 From: "Joseph D. Cohen" Date: Sat, 28 Sep 2024 14:43:23 -0700 Subject: [PATCH 1/3] Link Names of PNW Provisionals to DDD --- app/models/name/taxonomy.rb | 4 +++ .../names/show/_nomenclature.html.erb | 3 +++ test/controllers/names_controller_test.rb | 25 +++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/app/models/name/taxonomy.rb b/app/models/name/taxonomy.rb index 36061fc9b4..2426e1ec77 100644 --- a/app/models/name/taxonomy.rb +++ b/app/models/name/taxonomy.rb @@ -95,6 +95,10 @@ def unsearchable_in_registry? /\bcrypt temp\b/i =~ author&.delete(".") end + def pnw_provisional? + text_name.match?(/".*pnw/i) || author.match(/pnw/i) + end + ################ private diff --git a/app/views/controllers/names/show/_nomenclature.html.erb b/app/views/controllers/names/show/_nomenclature.html.erb index b7cb9be6cf..016cbdb664 100644 --- a/app/views/controllers/names/show/_nomenclature.html.erb +++ b/app/views/controllers/names/show/_nomenclature.html.erb @@ -76,6 +76,9 @@ synonym_links = [approve, deprecate].reject(&:nil?).safe_join(" | ") tag.p(link_to(*index_fungorum_name_search_tab(name))), tag.p(link_to(*mycobank_basic_search_tab)) ].safe_join + elsif name.pnw_provisional? + tag.p(link_to("DDD (PNW DNA-based taxa)", + "https://www.alpental.com/psms/ddd/index.htm")) end end) diff --git a/test/controllers/names_controller_test.rb b/test/controllers/names_controller_test.rb index cca91b946e..d62e3480d4 100644 --- a/test/controllers/names_controller_test.rb +++ b/test/controllers/names_controller_test.rb @@ -624,6 +624,31 @@ def test_show_name_ascomycete assert_external_link("Ascomycete.org", ascomycete_org_name_url(name)) end + def test_show_name_pnw_cryptonym + name = Name.create( + user_id: rolf.id, + rank: "Species", + text_name: 'Hygrocybe "parvula-PNW01"', + search_name: "Hygrocybe \"parvula-PNW01\" S.D. Russell crypt. temp.", + display_name: '**__Hygrocybe "parvula-PNW01"__** S.D. Russell crypt. temp.', + sort_name: 'Hygrocybe "parvula-PNW01" S.D. Russell crypt. temp.', + citation: "", + deprecated: false, + synonym_id: nil, + correct_spelling_id: nil, + classification: + "Domain: _Eukarya_\r\nKingdom: _Fungi_\r\nPhylum: _Basidiomycota_\r\nClass: _Agaricomycetes_\r\nOrder: _Agaricales_\r\nFamily: _Hygrophoraceae_", # rubocop:disable Layout/LineLength + author: "S.D. Russell crypt. temp." + ) + + login + get(:show, params: { id: name.id }) + + assert_select("div#nomenclature a:match('href',?)", + %r{https://www.alpental.com/psms/ddd/index.htm}, true, + "Page is missing a link to PNW cryptonym page") + end + def test_show_name_genus_with_icn_id # Name's icn_id is filled in name = names(:tubaria) From 36562372596630c8294650ab7d70b26ca38d9767 Mon Sep 17 00:00:00 2001 From: "Joseph D. Cohen" Date: Sat, 28 Sep 2024 19:49:45 -0700 Subject: [PATCH 2/3] Add DDD links to show Name & show Observation - DDD == Danny's DNA Discoveries -- project to document all mushrooms species that occur in the Pacific Northwest based on DNA analysis --- app/helpers/object_link_helper.rb | 4 +++ app/helpers/tabs/names_helper.rb | 5 +++ app/helpers/tabs/observations_helper.rb | 8 +++-- .../names/show/_nomenclature.html.erb | 3 +- config/locales/en.txt | 1 + .../observations_controller_show_test.rb | 34 +++++++++++++++++++ 6 files changed, 50 insertions(+), 5 deletions(-) diff --git a/app/helpers/object_link_helper.rb b/app/helpers/object_link_helper.rb index 76bc47a118..1b5cfe1c13 100644 --- a/app/helpers/object_link_helper.rb +++ b/app/helpers/object_link_helper.rb @@ -67,6 +67,10 @@ def ascomycete_org_name_url(name) "https://ascomycete.org/Search-Results?search=#{name.sensu_stricto}" end + def ddd_url + "https://www.alpental.com/psms/ddd/index.htm" + end + def gbif_name_search_url(name) # omit `group`, else there are no hits # omit quotes around the name in order to get synonyms and cf's diff --git a/app/helpers/tabs/names_helper.rb b/app/helpers/tabs/names_helper.rb index 887787af9b..ee87560b64 100644 --- a/app/helpers/tabs/names_helper.rb +++ b/app/helpers/tabs/names_helper.rb @@ -148,6 +148,11 @@ def google_images_for_name_tab(name) { class: tab_id(__method__.to_s), target: :_blank, rel: :noopener }] end + def ddd_link_tab + [:show_observation_ddd.l, ddd_url, + { class: tab_id(__method__.to_s), target: :_blank, rel: :noopener }] + end + def ascomycete_org_name_tab(name) ["Ascomycete.org", ascomycete_org_name_url(name), { class: tab_id(__method__.to_s), target: :_blank, rel: :noopener }] diff --git a/app/helpers/tabs/observations_helper.rb b/app/helpers/tabs/observations_helper.rb index b7ef8349cb..24b9af17d6 100644 --- a/app/helpers/tabs/observations_helper.rb +++ b/app/helpers/tabs/observations_helper.rb @@ -94,9 +94,11 @@ def name_links_web(name:) end def observation_web_name_tabs(name) - [mycoportal_name_tab(name), - mycobank_name_search_tab(name), - google_images_for_name_tab(name)] + tabs = [mycoportal_name_tab(name), + mycobank_name_search_tab(name), + google_images_for_name_tab(name)] + tabs << ddd_link_tab if name.pnw_provisional? + tabs end def observation_hide_thumbnail_map_tab(obs) diff --git a/app/views/controllers/names/show/_nomenclature.html.erb b/app/views/controllers/names/show/_nomenclature.html.erb index 016cbdb664..7fbc2fc94b 100644 --- a/app/views/controllers/names/show/_nomenclature.html.erb +++ b/app/views/controllers/names/show/_nomenclature.html.erb @@ -77,8 +77,7 @@ synonym_links = [approve, deprecate].reject(&:nil?).safe_join(" | ") tag.p(link_to(*mycobank_basic_search_tab)) ].safe_join elsif name.pnw_provisional? - tag.p(link_to("DDD (PNW DNA-based taxa)", - "https://www.alpental.com/psms/ddd/index.htm")) + tag.p(link_to(:show_observation_ddd.l, ddd_url)) end end) diff --git a/config/locales/en.txt b/config/locales/en.txt index 4e35d9db9c..858684daec 100644 --- a/config/locales/en.txt +++ b/config/locales/en.txt @@ -2316,6 +2316,7 @@ show_observation_more_like_this: More like this show_observation_look_alikes: Look-alikes show_observation_related_taxa: Related taxa + show_observation_ddd: "DDD (PNW DNA-based taxa)" map_observation_title: "Map of Observation #[ID]" # observations/suggestions diff --git a/test/controllers/observations_controller/observations_controller_show_test.rb b/test/controllers/observations_controller/observations_controller_show_test.rb index 469cfa7a2c..e0cf2faeec 100644 --- a/test/controllers/observations_controller/observations_controller_show_test.rb +++ b/test/controllers/observations_controller/observations_controller_show_test.rb @@ -288,6 +288,40 @@ def test_observation_external_links_exist end end + def test_observation_pnw_link_exists + name = Name.create( + user_id: rolf.id, + rank: "Species", + text_name: 'Hygrocybe "parvula-PNW01"', + search_name: "Hygrocybe \"parvula-PNW01\" S.D. Russell crypt. temp.", + display_name: '**__Hygrocybe "parvula-PNW01"__** S.D. Russell crypt. temp.', + sort_name: 'Hygrocybe "parvula-PNW01" S.D. Russell crypt. temp.', + citation: "", + deprecated: false, + synonym_id: nil, + correct_spelling_id: nil, + classification: + "Domain: _Eukarya_\r\nKingdom: _Fungi_\r\nPhylum: _Basidiomycota_\r\nClass: _Agaricomycetes_\r\nOrder: _Agaricales_\r\nFamily: _Hygrophoraceae_", # rubocop:disable Layout/LineLength + author: "S.D. Russell crypt. temp." + ) + obs = Observation.create( + name: name, + location: locations(:obs_default_location), + where: "MO Inc., 68 Bay Rd., North Falmouth, Massachusetts, USA", + user: rolf, + is_collection_location: 1, + text_name: name.text_name, + classification: "name.classification" + ) + + login + get(:show, params: { id: obs.id }) + + assert_select("a:match('href',?)", + %r{https://www.alpental.com/psms/ddd/index.htm}, true, + "Page is missing a link to PNW cryptonym page") + end + def test_show_observation_edit_links obs = observations(:detailed_unknown_obs) proj = projects(:bolete_project) From 2f12c542b44771ee164999675139528f9f774975 Mon Sep 17 00:00:00 2001 From: "Joseph D. Cohen" Date: Sun, 29 Sep 2024 06:18:53 -0700 Subject: [PATCH 3/3] DDD link on Obs page if any proposal is pnw provisional --- app/helpers/tabs/observations_helper.rb | 18 +++++++++++------- .../observations/show/_name_info.erb | 2 +- .../observations_controller_show_test.rb | 11 ++--------- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/app/helpers/tabs/observations_helper.rb b/app/helpers/tabs/observations_helper.rb index 24b9af17d6..7982199e0a 100644 --- a/app/helpers/tabs/observations_helper.rb +++ b/app/helpers/tabs/observations_helper.rb @@ -87,20 +87,24 @@ def observation_map_tab(mappable) { class: tab_id(__method__.to_s) }] end - def name_links_web(name:) - tabs = create_links_to(observation_web_name_tabs(name), + def name_links_web(observation:) + tabs = create_links_to(observation_web_name_tabs(observation), { class: "d-block" }) tabs.reject(&:empty?) end - def observation_web_name_tabs(name) - tabs = [mycoportal_name_tab(name), - mycobank_name_search_tab(name), - google_images_for_name_tab(name)] - tabs << ddd_link_tab if name.pnw_provisional? + def observation_web_name_tabs(observation) + tabs = [mycoportal_name_tab(observation.name), + mycobank_name_search_tab(observation.name), + google_images_for_name_tab(observation.name)] + tabs << ddd_link_tab if namings_pnw_provisional?(observation) tabs end + def namings_pnw_provisional?(observation) + observation.namings.any? { |naming| naming.name.pnw_provisional? } + end + def observation_hide_thumbnail_map_tab(obs) [:show_observation_hide_map.l, javascript_hide_thumbnail_map_path(id: obs.id), diff --git a/app/views/controllers/observations/show/_name_info.erb b/app/views/controllers/observations/show/_name_info.erb index 9a5ea43184..0bf14e1176 100644 --- a/app/views/controllers/observations/show/_name_info.erb +++ b/app/views/controllers/observations/show/_name_info.erb @@ -16,7 +16,7 @@ panel_block( end %> <%= tag.div(class: "col-xs-6") do concat(tag.div("#{:on_the_web.l}:", class: "font-weight-bold")) - concat(name_links_web(name: obs.name).safe_join) + concat(name_links_web(observation: @observation).safe_join) end %> <% end %> diff --git a/test/controllers/observations_controller/observations_controller_show_test.rb b/test/controllers/observations_controller/observations_controller_show_test.rb index e0cf2faeec..c87f1ec2b3 100644 --- a/test/controllers/observations_controller/observations_controller_show_test.rb +++ b/test/controllers/observations_controller/observations_controller_show_test.rb @@ -289,6 +289,7 @@ def test_observation_external_links_exist end def test_observation_pnw_link_exists + obs = observations(:minimal_unknown_obs) name = Name.create( user_id: rolf.id, rank: "Species", @@ -304,15 +305,7 @@ def test_observation_pnw_link_exists "Domain: _Eukarya_\r\nKingdom: _Fungi_\r\nPhylum: _Basidiomycota_\r\nClass: _Agaricomycetes_\r\nOrder: _Agaricales_\r\nFamily: _Hygrophoraceae_", # rubocop:disable Layout/LineLength author: "S.D. Russell crypt. temp." ) - obs = Observation.create( - name: name, - location: locations(:obs_default_location), - where: "MO Inc., 68 Bay Rd., North Falmouth, Massachusetts, USA", - user: rolf, - is_collection_location: 1, - text_name: name.text_name, - classification: "name.classification" - ) + Naming.create(observation: obs, name: name, vote_cache: 0, user: rolf) login get(:show, params: { id: obs.id })