lib/decidim/plans/plan_serializer.rb in decidim-plans-0.16.9 vs lib/decidim/plans/plan_serializer.rb in decidim-plans-0.17.0

- old
+ new

@@ -15,10 +15,11 @@ # Public: Exports a hash with the serialized data for this proposal. def serialize values = { id: plan.id, + authors: author_details, category: { id: plan.category.try(:id), name: plan.category.try(:name) }, scope: { @@ -58,19 +59,29 @@ private attr_reader :plan + def author_details + plan.authors.map do |author| + "#{author.class}/#{author.id}" + end + end + def component plan.component end + def related_proposals + plan.linked_resources(:proposals, "included_proposals") + end + def related_proposal_ids - plan.proposals.map(&:id) + related_proposals.map(&:id) end def related_proposal_urls - plan.proposals.map do |proposal| + related_proposals.map do |proposal| Decidim::ResourceLocatorPresenter.new(proposal).url end end def url