diff --git a/app/models/m_taxon_concept.rb b/app/models/m_taxon_concept.rb index 966f47e04..1766bb6ee 100644 --- a/app/models/m_taxon_concept.rb +++ b/app/models/m_taxon_concept.rb @@ -153,6 +153,7 @@ class MTaxonConcept < ApplicationRecord class_name: 'MCmsListingChange' has_many :cites_processes + has_many :distributions, foreign_key: :taxon_concept_id scope :by_cites_eu_taxonomy, -> { where(taxonomy_is_cites_eu: true) } scope :by_cms_taxonomy, -> { where(taxonomy_is_cites_eu: false) } diff --git a/app/serializers/checklist/distribution_serializer.rb b/app/serializers/checklist/distribution_serializer.rb new file mode 100644 index 000000000..be44556c4 --- /dev/null +++ b/app/serializers/checklist/distribution_serializer.rb @@ -0,0 +1,7 @@ +class Checklist::DistributionSerializer < ActiveModel::Serializer + attributes :geo_entity_id, :tag_names + + def tag_names + object.tags.map(&:name) + end +end diff --git a/app/serializers/checklist/taxon_concept_serializer.rb b/app/serializers/checklist/taxon_concept_serializer.rb index 5301b1428..b08d5dc87 100644 --- a/app/serializers/checklist/taxon_concept_serializer.rb +++ b/app/serializers/checklist/taxon_concept_serializer.rb @@ -10,6 +10,9 @@ class Checklist::TaxonConceptSerializer < ActiveModel::Serializer has_many :current_cites_additions, serializer: Checklist::ListingChangeSerializer, key: :current_additions + has_many :distributions, serializer: Checklist::DistributionSerializer, + key: :distributions + def id if object.is_a? Checklist::HigherTaxaItem object.id + 1000000 # unless ids differ, Ember will create a single object