app/models/tramea.rb
# NOTE: It's assumed you're calling this FROM a taxon_concept, so the TC
# isn't part of the returned data.
It's assumed you're calling this FROM a taxon_concept, so the TC
isn't part of the returned data.
It ' s assumed you ' re calling this FROM a taxon_concept so the TC isn ' t part of the returned data .
def common_name_from_taxon_concept_name(tcn)
      sources = tcn.agents.map do |agent|
        if agent.user
          {
            "name" => agent.user.full_name,
            "type" => "user",
            "id" => agent.user.id
          }
        else
          { "name" => agent.full_name, "type" => "agent", "id" => agent.id }
        end
      end
      sources += tcn.hierarchies.map do |hierarchy|
        {
          "name" => hierarchy.resource.title,
          "content_partner_id" => hierarchy.content_partner.id,
          "id" => hierarchy.resource.id,
          "type" => "resource"
        }
      end
      sources << { "name" => "uBio", "type" => "default" } if sources.empty?
      {
        "language" => tcn.language.iso_639_1,
        "name" => tcn.name.string,
        "sources" => sources,
        "trusted" => tcn.vetted_id == Vetted.trusted.id,
        "preferred" => tcn.preferred?
      }
    end
def common_name_from_taxon_concept_name ( tcn ) sources = tcn . agents . map do | agent | if agent . user { "name" => agent . user . full_name , "type" => "user" , "id" => agent . user . id } else { "name" => agent . full_name , "type" => "agent" , "id" => agent . id } end end sources += tcn . hierarchies . map do | hierarchy | { "name" => hierarchy . resource . title , "content_partner_id" => hierarchy . content_partner . id , "id" => hierarchy . resource . id , "type" => "resource" } end sources << { "name" => "uBio" , "type" => "default" } if sources . empty? { "language" => tcn . language . iso_639_1 , "name" => tcn . name . string , "sources" => sources , "trusted" => tcn . vetted_id == Vetted . trusted . id , "preferred" => tcn . preferred? } end
NOTE: It's assumed you're calling this FROM a taxon_concept, so the TC
isn't part of the returned data.
NOTE : It ' s assumed you ' re calling this FROM a taxon_concept so the TC isn ' t part of the returned data .
# NOTE: I'm duplicating logic from TaxaHelper#common_name_display_attribution # NOTE: I don't believe anyone will ever be able to use the agent id: # NOTE: content_partner is a METHOD, not an association, here: # OMG. ...If a name has no other attribution, it's considered to be uBio. # Yes, really. THIS IS SO LAME.  TODO: fix this in the db (then clean up # the code in the helper, at least)
tcn
<not_specific>